go-teeworlds-protocol/messages7/sv_chat.go

59 lines
1.1 KiB
Go
Raw Normal View History

2024-06-20 05:27:46 +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 05:27:46 +00:00
)
type SvChat struct {
2024-06-21 01:50:46 +00:00
ChunkHeader *chunk7.ChunkHeader
2024-06-20 05:27:46 +00:00
Mode int
ClientId int
TargetId int
Message string
}
func (msg SvChat) MsgId() int {
return network7.MsgGameSvChat
}
func (msg SvChat) MsgType() network7.MsgType {
return network7.TypeNet
}
func (msg SvChat) System() bool {
return false
}
func (msg SvChat) Vital() bool {
return true
}
func (msg SvChat) Pack() []byte {
return slices.Concat(
packer.PackInt(msg.Mode),
packer.PackInt(msg.ClientId),
packer.PackInt(msg.TargetId),
packer.PackStr(msg.Message),
)
}
func (msg *SvChat) Unpack(u *packer.Unpacker) {
msg.Mode = u.GetInt()
msg.ClientId = u.GetInt()
msg.TargetId = u.GetInt()
msg.Message = u.GetString()
}
func (msg *SvChat) Header() *chunk7.ChunkHeader {
2024-06-21 01:50:46 +00:00
return msg.ChunkHeader
}
func (msg *SvChat) SetHeader(header *chunk7.ChunkHeader) {
2024-06-21 01:50:46 +00:00
msg.ChunkHeader = header
}