go-teeworlds-protocol/messages7/ctrl_connect.go

50 lines
906 B
Go
Raw Permalink Normal View History

2024-06-20 03:08:52 +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-20 03:08:52 +00:00
)
type CtrlConnect struct {
Token [4]byte
}
func (msg *CtrlConnect) MsgId() int {
2024-06-20 03:08:52 +00:00
return network7.MsgCtrlConnect
}
func (msg *CtrlConnect) MsgType() network7.MsgType {
2024-06-20 03:08:52 +00:00
return network7.TypeControl
}
func (msg *CtrlConnect) System() bool {
2024-06-20 03:08:52 +00:00
return false
}
func (msg *CtrlConnect) Vital() bool {
2024-06-20 03:08:52 +00:00
return false
}
func (msg *CtrlConnect) Pack() []byte {
2024-06-20 03:08:52 +00:00
return slices.Concat(
[]byte{network7.MsgCtrlConnect},
msg.Token[:],
[]byte{512: 0},
)
}
func (msg *CtrlConnect) Unpack(u *packer.Unpacker) error {
msg.Token = [4]byte(u.Rest())
return nil
}
func (msg *CtrlConnect) Header() *chunk7.ChunkHeader {
return nil
}
func (msg *CtrlConnect) SetHeader(header *chunk7.ChunkHeader) {
}