-
Notifications
You must be signed in to change notification settings - Fork 1
/
msg_continue.go
56 lines (46 loc) · 1.12 KB
/
msg_continue.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package gtp
import (
"git.golaxy.org/framework/util/binaryutil"
)
// MsgContinue 重连
type MsgContinue struct {
SendSeq uint32 // 客户端请求消息序号
RecvSeq uint32 // 客户端响应消息序号
}
// Read implements io.Reader
func (m MsgContinue) Read(p []byte) (int, error) {
bs := binaryutil.NewBigEndianStream(p)
if err := bs.WriteUint32(m.SendSeq); err != nil {
return bs.BytesWritten(), err
}
if err := bs.WriteUint32(m.RecvSeq); err != nil {
return bs.BytesWritten(), err
}
return bs.BytesWritten(), nil
}
// Write implements io.Writer
func (m *MsgContinue) Write(p []byte) (int, error) {
bs := binaryutil.NewBigEndianStream(p)
var err error
m.SendSeq, err = bs.ReadUint32()
if err != nil {
return bs.BytesRead(), err
}
m.RecvSeq, err = bs.ReadUint32()
if err != nil {
return bs.BytesRead(), err
}
return bs.BytesRead(), nil
}
// Size 大小
func (MsgContinue) Size() int {
return binaryutil.SizeofUint32() + binaryutil.SizeofUint32()
}
// MsgId 消息Id
func (MsgContinue) MsgId() MsgId {
return MsgId_Continue
}
// Clone 克隆消息对象
func (m MsgContinue) Clone() Msg {
return &m
}