summaryrefslogtreecommitdiffstats
path: root/core/data.go
blob: 0bd8200f95d0fc274d38f99c59bfd95a52aadf9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package core

type Marshaler interface {
	Marshal() []any
}

type DataType uint8

const (
	TypeUnknown   DataType = 0x00
	TypeHandshake          = 0x01
	TypePing               = 0x02
	TypePong               = 0x03
	TypeTest               = 0xFF
)

type Handshake struct {
	Version uint8
}

func (h Handshake) Marshal() []any {
	return []any{h.Version}
}

type Test struct {
	Message string
}

func (h Test) Marshal() []any {
	return []any{append([]byte(h.Message), 0x0)}
}