diff options
Diffstat (limited to 'demo/qwd/data.go')
| -rw-r--r-- | demo/qwd/data.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/demo/qwd/data.go b/demo/qwd/data.go new file mode 100644 index 0000000..cc00c23 --- /dev/null +++ b/demo/qwd/data.go @@ -0,0 +1,32 @@ +package qwd + +import ( + "github.com/osm/quake/common/buffer" + "github.com/osm/quake/protocol" +) + +type Data struct { + Timestamp float32 + Command byte + Cmd *Cmd + Read *Read + Set *Set +} + +func (d *Data) Bytes() []byte { + buf := buffer.New() + + buf.PutFloat32(d.Timestamp) + buf.PutByte(d.Command) + + switch d.Command { + case protocol.DemoCmd: + buf.PutBytes(d.Cmd.Bytes()) + case protocol.DemoRead: + buf.PutBytes(d.Read.Bytes()) + case protocol.DemoSet: + buf.PutBytes(d.Set.Bytes()) + } + + return buf.Bytes() +} |
