tractor.dev/toolkit-go@v0.0.0-20241010005851-214d91207d07/duplex/mux/frame/message_openconfirm.go (about) 1 package frame 2 3 import ( 4 "bytes" 5 "encoding/binary" 6 "fmt" 7 ) 8 9 type OpenConfirmMessage struct { 10 ChannelID uint32 11 SenderID uint32 12 WindowSize uint32 13 MaxPacketSize uint32 14 } 15 16 func (msg OpenConfirmMessage) String() string { 17 return fmt.Sprintf("{OpenConfirmMessage ChannelID:%d SenderID:%d WindowSize:%d MaxPacketSize:%d}", 18 msg.ChannelID, msg.SenderID, msg.WindowSize, msg.MaxPacketSize) 19 } 20 21 func (msg OpenConfirmMessage) Channel() (uint32, bool) { 22 return msg.ChannelID, true 23 } 24 25 func (msg OpenConfirmMessage) Bytes() []byte { 26 buf := new(bytes.Buffer) 27 buf.WriteByte(msgChannelOpenConfirm) 28 binary.Write(buf, binary.BigEndian, msg) 29 return buf.Bytes() 30 }