go-teeworlds-protocol/messages7/ctrl_close.go

50 lines
899 B
Go
Raw Normal View History

2024-06-21 03:21:48 +00:00
package messages7
import (
"slices"
"github.com/teeworlds-go/go-teeworlds-protocol/chunk7"
"github.com/teeworlds-go/go-teeworlds-protocol/network7"
"github.com/teeworlds-go/go-teeworlds-protocol/packer"
2024-06-21 03:21:48 +00:00
)
type CtrlClose struct {
Reason string
}
func (msg *CtrlClose) MsgId() int {
2024-06-21 03:21:48 +00:00
return network7.MsgCtrlClose
}
func (msg *CtrlClose) MsgType() network7.MsgType {
2024-06-21 03:21:48 +00:00
return network7.TypeControl
}
func (msg *CtrlClose) System() bool {
2024-06-21 03:21:48 +00:00
return false
}
func (msg *CtrlClose) Vital() bool {
2024-06-21 03:21:48 +00:00
return false
}
func (msg *CtrlClose) Pack() []byte {
2024-06-21 03:21:48 +00:00
return slices.Concat(
[]byte{network7.MsgCtrlClose},
packer.PackStr(msg.Reason),
)
}
func (msg *CtrlClose) Unpack(u *packer.Unpacker) error {
2024-06-21 03:21:48 +00:00
// TODO: sanitize
msg.Reason, _ = u.GetString()
return nil
2024-06-21 03:21:48 +00:00
}
func (msg *CtrlClose) Header() *chunk7.ChunkHeader {
return nil
}
func (msg *CtrlClose) SetHeader(header *chunk7.ChunkHeader) {
}