go-teeworlds-protocol/messages7/ctrl_token.go

53 lines
1,005 B
Go
Raw Normal View History

2024-06-20 03:08:52 +00:00
package messages7
// this message is shared between client and server
// but this implementation is assuming we are sending from a client
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 CtrlToken struct {
Token [4]byte
}
func (msg *CtrlToken) MsgId() int {
2024-06-20 03:08:52 +00:00
return network7.MsgCtrlToken
}
func (msg *CtrlToken) MsgType() network7.MsgType {
2024-06-20 03:08:52 +00:00
return network7.TypeControl
}
func (msg *CtrlToken) System() bool {
2024-06-20 03:08:52 +00:00
return false
}
func (msg *CtrlToken) Vital() bool {
2024-06-20 03:08:52 +00:00
return false
}
func (msg *CtrlToken) Pack() []byte {
2024-06-20 03:08:52 +00:00
return slices.Concat(
[]byte{network7.MsgCtrlToken},
msg.Token[:],
[]byte{512: 0},
)
}
func (msg *CtrlToken) Unpack(u *packer.Unpacker) error {
msg.Token = [4]byte(u.Rest())
return nil
}
func (msg *CtrlToken) Header() *chunk7.ChunkHeader {
return nil
}
func (msg *CtrlToken) SetHeader(header *chunk7.ChunkHeader) {
}