aboutsummaryrefslogtreecommitdiffstats
path: root/demo/mvd/set.go
blob: 8cc4c9573b97fc5ad118c33ad152e48f2b0f76eb (plain) (blame)
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
32
33
34
35
package mvd

import (
	"github.com/osm/quake/common/buffer"
	"github.com/osm/quake/common/context"
)

type Set struct {
	SeqOut uint32
	SeqIn  uint32
}

func (cmd *Set) Bytes() []byte {
	buf := buffer.New()

	buf.PutUint32(cmd.SeqOut)
	buf.PutUint32(cmd.SeqIn)

	return buf.Bytes()
}

func parseSet(ctx *context.Context, buf *buffer.Buffer) (*Set, error) {
	var err error
	var cmd Set

	if cmd.SeqOut, err = buf.GetUint32(); err != nil {
		return nil, err
	}

	if cmd.SeqIn, err = buf.GetUint32(); err != nil {
		return nil, err
	}

	return &cmd, nil
}