Skip to content

Commit

Permalink
Add ctrl close
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillerDragon committed Jun 21, 2024
1 parent 4d05818 commit 88a312a
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions messages7/ctrl_close.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package messages7

import (
"slices"

"github.com/teeworlds-go/teeworlds/chunk7"
"github.com/teeworlds-go/teeworlds/network7"
"github.com/teeworlds-go/teeworlds/packer"
)

type CtrlClose struct {
Reason string
}

func (msg CtrlClose) MsgId() int {
return network7.MsgCtrlClose
}

func (msg CtrlClose) MsgType() network7.MsgType {
return network7.TypeControl
}

func (msg CtrlClose) System() bool {
return false
}

func (msg CtrlClose) Vital() bool {
return false
}

func (msg CtrlClose) Pack() []byte {
return slices.Concat(
[]byte{network7.MsgCtrlClose},
packer.PackStr(msg.Reason),
)
}

func (msg *CtrlClose) Unpack(u *packer.Unpacker) {
// TODO: sanitize
msg.Reason = u.GetString()
}

func (msg *CtrlClose) Header() *chunk7.ChunkHeader {
return nil
}

func (msg *CtrlClose) SetHeader(header *chunk7.ChunkHeader) {
}

0 comments on commit 88a312a

Please sign in to comment.