2024-06-20 05:27:46 +00:00
|
|
|
package messages7
|
|
|
|
|
|
|
|
import (
|
|
|
|
"slices"
|
|
|
|
|
2024-06-22 05:59:27 +00:00
|
|
|
"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-21 01:38:59 +00:00
|
|
|
|
2024-06-23 05:05:57 +00:00
|
|
|
Mode network7.ChatMode
|
2024-06-20 05:27:46 +00:00
|
|
|
ClientId int
|
|
|
|
TargetId int
|
|
|
|
Message string
|
|
|
|
}
|
|
|
|
|
2024-06-23 19:18:54 +00:00
|
|
|
func (msg *SvChat) MsgId() int {
|
2024-06-20 05:27:46 +00:00
|
|
|
return network7.MsgGameSvChat
|
|
|
|
}
|
|
|
|
|
2024-06-23 19:18:54 +00:00
|
|
|
func (msg *SvChat) MsgType() network7.MsgType {
|
2024-06-20 05:27:46 +00:00
|
|
|
return network7.TypeNet
|
|
|
|
}
|
|
|
|
|
2024-06-23 19:18:54 +00:00
|
|
|
func (msg *SvChat) System() bool {
|
2024-06-20 05:27:46 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2024-06-23 19:18:54 +00:00
|
|
|
func (msg *SvChat) Vital() bool {
|
2024-06-20 05:27:46 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-06-23 19:18:54 +00:00
|
|
|
func (msg *SvChat) Pack() []byte {
|
2024-06-20 05:27:46 +00:00
|
|
|
return slices.Concat(
|
2024-06-23 05:05:57 +00:00
|
|
|
packer.PackInt(int(msg.Mode)),
|
2024-06-20 05:27:46 +00:00
|
|
|
packer.PackInt(msg.ClientId),
|
|
|
|
packer.PackInt(msg.TargetId),
|
|
|
|
packer.PackStr(msg.Message),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2024-06-23 19:18:54 +00:00
|
|
|
func (msg *SvChat) Unpack(u *packer.Unpacker) error {
|
2024-06-23 05:05:57 +00:00
|
|
|
msg.Mode = network7.ChatMode(u.GetInt())
|
2024-06-20 05:27:46 +00:00
|
|
|
msg.ClientId = u.GetInt()
|
|
|
|
msg.TargetId = u.GetInt()
|
2024-06-25 04:19:51 +00:00
|
|
|
msg.Message, _ = u.GetString()
|
2024-06-23 19:18:54 +00:00
|
|
|
|
|
|
|
return nil
|
2024-06-20 05:27:46 +00:00
|
|
|
}
|
2024-06-21 01:38:59 +00:00
|
|
|
|
|
|
|
func (msg *SvChat) Header() *chunk7.ChunkHeader {
|
2024-06-21 01:50:46 +00:00
|
|
|
return msg.ChunkHeader
|
2024-06-21 01:38:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (msg *SvChat) SetHeader(header *chunk7.ChunkHeader) {
|
2024-06-21 01:50:46 +00:00
|
|
|
msg.ChunkHeader = header
|
2024-06-21 01:38:59 +00:00
|
|
|
}
|