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