add
This commit is contained in:
parent
6ad90d18aa
commit
79a278a90f
@ -217,9 +217,10 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
|
||||
loggo.Info("client accept new local tcp %s %s", uuid, tcpsrcaddr.String())
|
||||
|
||||
loggo.Info("start connect remote tcp %s %s", uuid, tcpsrcaddr.String())
|
||||
clientConn.fm.Connect()
|
||||
startConnectTime := time.Now()
|
||||
for {
|
||||
if clientConn.fm.IsRemoteConnected() {
|
||||
if clientConn.fm.IsConnected() {
|
||||
break
|
||||
}
|
||||
clientConn.fm.Update()
|
||||
|
168
framemgr.go
168
framemgr.go
@ -35,7 +35,7 @@ type FrameMgr struct {
|
||||
reqmap map[int32]int64
|
||||
sendmap map[int32]int64
|
||||
|
||||
remote_connected bool
|
||||
connected bool
|
||||
}
|
||||
|
||||
func NewFrameMgr(buffersize int, windowsize int, resend_timems int) *FrameMgr {
|
||||
@ -51,7 +51,7 @@ func NewFrameMgr(buffersize int, windowsize int, resend_timems int) *FrameMgr {
|
||||
close: false, remoteclosed: false, closesend: false,
|
||||
lastPingTime: time.Now().UnixNano(), rttns: (int64)(resend_timems * 1000),
|
||||
reqmap: make(map[int32]int64), sendmap: make(map[int32]int64),
|
||||
remote_connected: false}
|
||||
connected: false}
|
||||
|
||||
return fm
|
||||
}
|
||||
@ -76,8 +76,6 @@ func (fm *FrameMgr) Update() {
|
||||
|
||||
fm.combineWindowToRecvBuffer()
|
||||
|
||||
fm.tryConnect()
|
||||
|
||||
fm.calSendList()
|
||||
|
||||
fm.ping()
|
||||
@ -85,10 +83,6 @@ func (fm *FrameMgr) Update() {
|
||||
|
||||
func (fm *FrameMgr) cutSendBufferToWindow() {
|
||||
|
||||
if !fm.remote_connected {
|
||||
return
|
||||
}
|
||||
|
||||
sendall := false
|
||||
|
||||
if fm.sendb.Size() < FRAME_MAX_SIZE {
|
||||
@ -96,10 +90,13 @@ func (fm *FrameMgr) cutSendBufferToWindow() {
|
||||
}
|
||||
|
||||
for fm.sendb.Size() >= FRAME_MAX_SIZE && fm.sendwin.Len() < fm.windowsize {
|
||||
f := &Frame{Type: (int32)(Frame_DATA), Resend: false, Sendtime: 0,
|
||||
Id: (int32)(fm.sendid),
|
||||
fd := &FrameData{Type: (int32)(FrameData_USER_DATA),
|
||||
Data: make([]byte, FRAME_MAX_SIZE)}
|
||||
fm.sendb.Read(f.Data)
|
||||
fm.sendb.Read(fd.Data)
|
||||
|
||||
f := &Frame{Type: (int32)(Frame_DATA),
|
||||
Id: (int32)(fm.sendid),
|
||||
Data: fd}
|
||||
|
||||
fm.sendid++
|
||||
if fm.sendid >= FRAME_MAX_ID {
|
||||
@ -111,10 +108,13 @@ func (fm *FrameMgr) cutSendBufferToWindow() {
|
||||
}
|
||||
|
||||
if sendall && fm.sendb.Size() > 0 && fm.sendwin.Len() < fm.windowsize {
|
||||
f := &Frame{Type: (int32)(Frame_DATA), Resend: false, Sendtime: 0,
|
||||
Id: (int32)(fm.sendid),
|
||||
fd := &FrameData{Type: (int32)(FrameData_USER_DATA),
|
||||
Data: make([]byte, fm.sendb.Size())}
|
||||
fm.sendb.Read(f.Data)
|
||||
fm.sendb.Read(fd.Data)
|
||||
|
||||
f := &Frame{Type: (int32)(Frame_DATA),
|
||||
Id: (int32)(fm.sendid),
|
||||
Data: fd}
|
||||
|
||||
fm.sendid++
|
||||
if fm.sendid >= FRAME_MAX_ID {
|
||||
@ -122,20 +122,22 @@ func (fm *FrameMgr) cutSendBufferToWindow() {
|
||||
}
|
||||
|
||||
fm.sendwin.PushBack(f)
|
||||
loggo.Debug("cut small frame push to send win %d %d %d", f.Id, len(f.Data), fm.sendwin.Len())
|
||||
loggo.Debug("cut small frame push to send win %d %d %d", f.Id, len(f.Data.Data), fm.sendwin.Len())
|
||||
}
|
||||
|
||||
if fm.sendb.Empty() && fm.close && !fm.closesend && fm.sendwin.Len() < fm.windowsize {
|
||||
f := &Frame{Type: (int32)(Frame_DATA), Resend: false, Sendtime: 0,
|
||||
fd := &FrameData{Type: (int32)(FrameData_CLOSE)}
|
||||
|
||||
f := &Frame{Type: (int32)(Frame_DATA),
|
||||
Id: (int32)(fm.sendid),
|
||||
Data: make([]byte, 0)}
|
||||
fm.sendwin.PushBack(f)
|
||||
Data: fd}
|
||||
|
||||
fm.sendid++
|
||||
if fm.sendid >= FRAME_MAX_ID {
|
||||
fm.sendid = 0
|
||||
}
|
||||
|
||||
fm.sendwin.PushBack(f)
|
||||
fm.closesend = true
|
||||
loggo.Debug("close frame push to send win %d %d", f.Id, fm.sendwin.Len())
|
||||
}
|
||||
@ -143,10 +145,6 @@ func (fm *FrameMgr) cutSendBufferToWindow() {
|
||||
|
||||
func (fm *FrameMgr) calSendList() {
|
||||
|
||||
if !fm.remote_connected {
|
||||
return
|
||||
}
|
||||
|
||||
cur := time.Now().UnixNano()
|
||||
for e := fm.sendwin.Front(); e != nil; e = e.Next() {
|
||||
f := e.Value.(*Frame)
|
||||
@ -157,7 +155,7 @@ func (fm *FrameMgr) calSendList() {
|
||||
fm.sendlist.PushBack(f)
|
||||
f.Resend = false
|
||||
fm.sendmap[f.Id] = cur
|
||||
loggo.Debug("push frame to sendlist %d %d", f.Id, len(f.Data))
|
||||
loggo.Debug("push frame to sendlist %d %d", f.Id, len(f.Data.Data))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -194,17 +192,13 @@ func (fm *FrameMgr) preProcessRecvList() (map[int32]int, map[int32]int, map[int3
|
||||
}
|
||||
} else if f.Type == (int32)(Frame_DATA) {
|
||||
tmpackto[f.Id] = f
|
||||
loggo.Debug("recv data %d %d", f.Id, len(f.Data))
|
||||
loggo.Debug("recv data %d %d", f.Id, len(f.Data.Data))
|
||||
} else if f.Type == (int32)(Frame_PING) {
|
||||
fm.processPing(f)
|
||||
} else if f.Type == (int32)(Frame_PONG) {
|
||||
fm.processPong(f)
|
||||
} else if f.Type == (int32)(Frame_REG) {
|
||||
fm.processReg(f)
|
||||
} else if f.Type == (int32)(Frame_REGACK) {
|
||||
fm.processRegAck(f)
|
||||
} else if f.Type == (int32)(Frame_REGAGAIN) {
|
||||
fm.processRegAgain(f)
|
||||
} else {
|
||||
loggo.Error("error frame type %s", f.Type)
|
||||
}
|
||||
}
|
||||
fm.recvlist.Init()
|
||||
@ -213,16 +207,12 @@ func (fm *FrameMgr) preProcessRecvList() (map[int32]int, map[int32]int, map[int3
|
||||
|
||||
func (fm *FrameMgr) processRecvList(tmpreq map[int32]int, tmpack map[int32]int, tmpackto map[int32]*Frame) {
|
||||
|
||||
if !fm.remote_connected {
|
||||
return
|
||||
}
|
||||
|
||||
for id, _ := range tmpreq {
|
||||
for e := fm.sendwin.Front(); e != nil; e = e.Next() {
|
||||
f := e.Value.(*Frame)
|
||||
if f.Id == id {
|
||||
f.Resend = true
|
||||
loggo.Debug("choose resend win %d %d", f.Id, len(f.Data))
|
||||
loggo.Debug("choose resend win %d %d", f.Id, len(f.Data.Data))
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -234,7 +224,7 @@ func (fm *FrameMgr) processRecvList(tmpreq map[int32]int, tmpack map[int32]int,
|
||||
if f.Id == id {
|
||||
fm.sendwin.Remove(e)
|
||||
delete(fm.sendmap, f.Id)
|
||||
loggo.Debug("remove send win %d %d", f.Id, len(f.Data))
|
||||
loggo.Debug("remove send win %d %d", f.Id, len(f.Data.Data))
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -247,7 +237,7 @@ func (fm *FrameMgr) processRecvList(tmpreq map[int32]int, tmpack map[int32]int,
|
||||
if fm.addToRecvWin(rf) {
|
||||
tmp[index] = id
|
||||
index++
|
||||
loggo.Debug("add data to win %d %d", rf.Id, len(rf.Data))
|
||||
loggo.Debug("add data to win %d %d", rf.Id, len(rf.Data.Data))
|
||||
}
|
||||
}
|
||||
if index > 0 {
|
||||
@ -273,7 +263,7 @@ func (fm *FrameMgr) addToRecvWin(rf *Frame) bool {
|
||||
for e := fm.recvwin.Front(); e != nil; e = e.Next() {
|
||||
f := e.Value.(*Frame)
|
||||
if f.Id == rf.Id {
|
||||
loggo.Debug("recv frame ignore %d %d", f.Id, len(f.Data))
|
||||
loggo.Debug("recv frame ignore %d %d", f.Id, len(f.Data.Data))
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -283,38 +273,58 @@ func (fm *FrameMgr) addToRecvWin(rf *Frame) bool {
|
||||
loggo.Debug("start insert recv win %d %d %d", fm.recvid, rf.Id, f.Id)
|
||||
if fm.compareId((int)(rf.Id), (int)(f.Id)) < 0 {
|
||||
fm.recvwin.InsertBefore(rf, e)
|
||||
loggo.Debug("insert recv win %d %d before %d", rf.Id, len(rf.Data), f.Id)
|
||||
loggo.Debug("insert recv win %d %d before %d", rf.Id, len(rf.Data.Data), f.Id)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
fm.recvwin.PushBack(rf)
|
||||
loggo.Debug("insert recv win last %d %d", rf.Id, len(rf.Data))
|
||||
loggo.Debug("insert recv win last %d %d", rf.Id, len(rf.Data.Data))
|
||||
return true
|
||||
}
|
||||
|
||||
func (fm *FrameMgr) combineWindowToRecvBuffer() {
|
||||
|
||||
if !fm.remote_connected {
|
||||
return
|
||||
func (fm *FrameMgr) processRecvFrame(f *Frame) bool {
|
||||
if f.Data.Type == (int32)(FrameData_USER_DATA) {
|
||||
left := fm.recvb.Capacity() - fm.recvb.Size()
|
||||
if left >= len(f.Data.Data) {
|
||||
fm.recvb.Write(f.Data.Data)
|
||||
loggo.Debug("combined recv frame to recv buffer %d %d",
|
||||
f.Id, len(f.Data.Data))
|
||||
return true
|
||||
}
|
||||
} else if f.Data.Type == (int32)(FrameData_CLOSE) {
|
||||
fm.remoteclosed = true
|
||||
loggo.Debug("recv remote close frame %d", f.Id)
|
||||
return true
|
||||
} else if f.Data.Type == (int32)(FrameData_CONN) {
|
||||
fm.sendConnectRsp()
|
||||
fm.connected = true
|
||||
loggo.Debug("recv remote conn frame %d", f.Id)
|
||||
return true
|
||||
} else if f.Data.Type == (int32)(FrameData_CONNRSP) {
|
||||
fm.connected = true
|
||||
loggo.Debug("recv remote conn rsp frame %d", f.Id)
|
||||
return true
|
||||
} else {
|
||||
loggo.Error("recv frame type error %d", f.Data.Type)
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (fm *FrameMgr) combineWindowToRecvBuffer() {
|
||||
|
||||
for {
|
||||
done := false
|
||||
for e := fm.recvwin.Front(); e != nil; e = e.Next() {
|
||||
f := e.Value.(*Frame)
|
||||
if f.Id == (int32)(fm.recvid) {
|
||||
left := fm.recvb.Capacity() - fm.recvb.Size()
|
||||
if left >= len(f.Data) {
|
||||
if len(f.Data) == 0 {
|
||||
fm.remoteclosed = true
|
||||
loggo.Debug("recv remote close frame %d", f.Id)
|
||||
}
|
||||
fm.recvb.Write(f.Data)
|
||||
delete(fm.reqmap, f.Id)
|
||||
if fm.processRecvFrame(f) {
|
||||
fm.recvwin.Remove(e)
|
||||
delete(fm.reqmap, f.Id)
|
||||
done = true
|
||||
loggo.Debug("combined recv frame to recv buffer %d %d", f.Id, len(f.Data))
|
||||
loggo.Debug("process recv frame ok %d %d",
|
||||
f.Id, len(f.Data.Data))
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -395,10 +405,6 @@ func (fm *FrameMgr) IsRemoteClosed() bool {
|
||||
}
|
||||
|
||||
func (fm *FrameMgr) ping() {
|
||||
if !fm.remote_connected {
|
||||
return
|
||||
}
|
||||
|
||||
cur := time.Now().UnixNano()
|
||||
if cur-fm.lastPingTime > (int64)(time.Second) {
|
||||
f := &Frame{Type: (int32)(Frame_PING), Resend: false, Sendtime: cur,
|
||||
@ -471,32 +477,38 @@ func (fm *FrameMgr) isIdOld(id int, maxid int) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (fm *FrameMgr) IsRemoteConnected() bool {
|
||||
return fm.remote_connected
|
||||
func (fm *FrameMgr) IsConnected() bool {
|
||||
return fm.connected
|
||||
}
|
||||
|
||||
func (fm *FrameMgr) tryConnect() {
|
||||
if !fm.remote_connected {
|
||||
f := &Frame{Type: (int32)(Frame_REG)}
|
||||
fm.sendlist.PushBack(f)
|
||||
loggo.Debug("try connect")
|
||||
func (fm *FrameMgr) Connect() {
|
||||
fd := &FrameData{Type: (int32)(FrameData_CONN)}
|
||||
|
||||
f := &Frame{Type: (int32)(Frame_DATA),
|
||||
Id: (int32)(fm.sendid),
|
||||
Data: fd}
|
||||
|
||||
fm.sendid++
|
||||
if fm.sendid >= FRAME_MAX_ID {
|
||||
fm.sendid = 0
|
||||
}
|
||||
|
||||
fm.sendwin.PushBack(f)
|
||||
loggo.Debug("start connect")
|
||||
}
|
||||
|
||||
func (fm *FrameMgr) processReg(f *Frame) {
|
||||
rf := &Frame{Type: (int32)(Frame_REGACK)}
|
||||
fm.sendlist.PushBack(rf)
|
||||
loggo.Debug("recv reg ")
|
||||
}
|
||||
func (fm *FrameMgr) sendConnectRsp() {
|
||||
fd := &FrameData{Type: (int32)(FrameData_CONNRSP)}
|
||||
|
||||
func (fm *FrameMgr) processRegAck(f *Frame) {
|
||||
rf := &Frame{Type: (int32)(Frame_REGAGAIN)}
|
||||
fm.sendlist.PushBack(rf)
|
||||
fm.remote_connected = true
|
||||
loggo.Debug("recv reg ack ")
|
||||
}
|
||||
f := &Frame{Type: (int32)(Frame_DATA),
|
||||
Id: (int32)(fm.sendid),
|
||||
Data: fd}
|
||||
|
||||
func (fm *FrameMgr) processRegAgain(f *Frame) {
|
||||
fm.remote_connected = true
|
||||
loggo.Debug("recv reg ack again ")
|
||||
fm.sendid++
|
||||
if fm.sendid >= FRAME_MAX_ID {
|
||||
fm.sendid = 0
|
||||
}
|
||||
|
||||
fm.sendwin.PushBack(f)
|
||||
loggo.Debug("send connect rsp")
|
||||
}
|
||||
|
183
msg.pb.go
183
msg.pb.go
@ -48,17 +48,45 @@ func (MyMsg_TYPE) EnumDescriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c06e4cca6c2cc899, []int{0, 0}
|
||||
}
|
||||
|
||||
type FrameData_TYPE int32
|
||||
|
||||
const (
|
||||
FrameData_USER_DATA FrameData_TYPE = 0
|
||||
FrameData_CONN FrameData_TYPE = 1
|
||||
FrameData_CONNRSP FrameData_TYPE = 2
|
||||
FrameData_CLOSE FrameData_TYPE = 3
|
||||
)
|
||||
|
||||
var FrameData_TYPE_name = map[int32]string{
|
||||
0: "USER_DATA",
|
||||
1: "CONN",
|
||||
2: "CONNRSP",
|
||||
3: "CLOSE",
|
||||
}
|
||||
|
||||
var FrameData_TYPE_value = map[string]int32{
|
||||
"USER_DATA": 0,
|
||||
"CONN": 1,
|
||||
"CONNRSP": 2,
|
||||
"CLOSE": 3,
|
||||
}
|
||||
|
||||
func (x FrameData_TYPE) String() string {
|
||||
return proto.EnumName(FrameData_TYPE_name, int32(x))
|
||||
}
|
||||
|
||||
func (FrameData_TYPE) EnumDescriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c06e4cca6c2cc899, []int{1, 0}
|
||||
}
|
||||
|
||||
type Frame_TYPE int32
|
||||
|
||||
const (
|
||||
Frame_DATA Frame_TYPE = 0
|
||||
Frame_REQ Frame_TYPE = 1
|
||||
Frame_ACK Frame_TYPE = 2
|
||||
Frame_PING Frame_TYPE = 3
|
||||
Frame_PONG Frame_TYPE = 4
|
||||
Frame_REG Frame_TYPE = 5
|
||||
Frame_REGACK Frame_TYPE = 6
|
||||
Frame_REGAGAIN Frame_TYPE = 7
|
||||
Frame_DATA Frame_TYPE = 0
|
||||
Frame_REQ Frame_TYPE = 1
|
||||
Frame_ACK Frame_TYPE = 2
|
||||
Frame_PING Frame_TYPE = 3
|
||||
Frame_PONG Frame_TYPE = 4
|
||||
)
|
||||
|
||||
var Frame_TYPE_name = map[int32]string{
|
||||
@ -67,20 +95,14 @@ var Frame_TYPE_name = map[int32]string{
|
||||
2: "ACK",
|
||||
3: "PING",
|
||||
4: "PONG",
|
||||
5: "REG",
|
||||
6: "REGACK",
|
||||
7: "REGAGAIN",
|
||||
}
|
||||
|
||||
var Frame_TYPE_value = map[string]int32{
|
||||
"DATA": 0,
|
||||
"REQ": 1,
|
||||
"ACK": 2,
|
||||
"PING": 3,
|
||||
"PONG": 4,
|
||||
"REG": 5,
|
||||
"REGACK": 6,
|
||||
"REGAGAIN": 7,
|
||||
"DATA": 0,
|
||||
"REQ": 1,
|
||||
"ACK": 2,
|
||||
"PING": 3,
|
||||
"PONG": 4,
|
||||
}
|
||||
|
||||
func (x Frame_TYPE) String() string {
|
||||
@ -88,7 +110,7 @@ func (x Frame_TYPE) String() string {
|
||||
}
|
||||
|
||||
func (Frame_TYPE) EnumDescriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c06e4cca6c2cc899, []int{1, 0}
|
||||
return fileDescriptor_c06e4cca6c2cc899, []int{2, 0}
|
||||
}
|
||||
|
||||
type MyMsg struct {
|
||||
@ -218,23 +240,70 @@ func (m *MyMsg) GetTimeout() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
type Frame struct {
|
||||
type FrameData struct {
|
||||
Type int32 `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"`
|
||||
Resend bool `protobuf:"varint,2,opt,name=resend,proto3" json:"resend,omitempty"`
|
||||
Sendtime int64 `protobuf:"varint,3,opt,name=sendtime,proto3" json:"sendtime,omitempty"`
|
||||
Id int32 `protobuf:"varint,4,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Data []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"`
|
||||
Dataid []int32 `protobuf:"varint,6,rep,packed,name=dataid,proto3" json:"dataid,omitempty"`
|
||||
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *FrameData) Reset() { *m = FrameData{} }
|
||||
func (m *FrameData) String() string { return proto.CompactTextString(m) }
|
||||
func (*FrameData) ProtoMessage() {}
|
||||
func (*FrameData) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c06e4cca6c2cc899, []int{1}
|
||||
}
|
||||
|
||||
func (m *FrameData) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_FrameData.Unmarshal(m, b)
|
||||
}
|
||||
func (m *FrameData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_FrameData.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *FrameData) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_FrameData.Merge(m, src)
|
||||
}
|
||||
func (m *FrameData) XXX_Size() int {
|
||||
return xxx_messageInfo_FrameData.Size(m)
|
||||
}
|
||||
func (m *FrameData) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_FrameData.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_FrameData proto.InternalMessageInfo
|
||||
|
||||
func (m *FrameData) GetType() int32 {
|
||||
if m != nil {
|
||||
return m.Type
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *FrameData) GetData() []byte {
|
||||
if m != nil {
|
||||
return m.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Frame struct {
|
||||
Type int32 `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"`
|
||||
Resend bool `protobuf:"varint,2,opt,name=resend,proto3" json:"resend,omitempty"`
|
||||
Sendtime int64 `protobuf:"varint,3,opt,name=sendtime,proto3" json:"sendtime,omitempty"`
|
||||
Id int32 `protobuf:"varint,4,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Data *FrameData `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"`
|
||||
Dataid []int32 `protobuf:"varint,6,rep,packed,name=dataid,proto3" json:"dataid,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Frame) Reset() { *m = Frame{} }
|
||||
func (m *Frame) String() string { return proto.CompactTextString(m) }
|
||||
func (*Frame) ProtoMessage() {}
|
||||
func (*Frame) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c06e4cca6c2cc899, []int{1}
|
||||
return fileDescriptor_c06e4cca6c2cc899, []int{2}
|
||||
}
|
||||
|
||||
func (m *Frame) XXX_Unmarshal(b []byte) error {
|
||||
@ -283,7 +352,7 @@ func (m *Frame) GetId() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Frame) GetData() []byte {
|
||||
func (m *Frame) GetData() *FrameData {
|
||||
if m != nil {
|
||||
return m.Data
|
||||
}
|
||||
@ -299,39 +368,43 @@ func (m *Frame) GetDataid() []int32 {
|
||||
|
||||
func init() {
|
||||
proto.RegisterEnum("MyMsg_TYPE", MyMsg_TYPE_name, MyMsg_TYPE_value)
|
||||
proto.RegisterEnum("FrameData_TYPE", FrameData_TYPE_name, FrameData_TYPE_value)
|
||||
proto.RegisterEnum("Frame_TYPE", Frame_TYPE_name, Frame_TYPE_value)
|
||||
proto.RegisterType((*MyMsg)(nil), "MyMsg")
|
||||
proto.RegisterType((*FrameData)(nil), "FrameData")
|
||||
proto.RegisterType((*Frame)(nil), "Frame")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("msg.proto", fileDescriptor_c06e4cca6c2cc899) }
|
||||
|
||||
var fileDescriptor_c06e4cca6c2cc899 = []byte{
|
||||
// 407 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x92, 0xcd, 0x8e, 0xd3, 0x30,
|
||||
0x14, 0x85, 0x71, 0x12, 0xa7, 0xe9, 0x9d, 0x32, 0xf2, 0x5c, 0x7e, 0x64, 0xb1, 0x8a, 0x2a, 0x21,
|
||||
0xb2, 0x81, 0x05, 0x3c, 0x41, 0x66, 0x28, 0x51, 0x85, 0x5a, 0x06, 0xab, 0x9b, 0x61, 0x33, 0xca,
|
||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58, 0xaf,
|
||||
0x07, 0xdd, 0x35, 0xb7, 0xce, 0x58, 0x6d, 0x07, 0x79, 0x46, 0xf4, 0x93, 0xb0, 0x54, 0xb4, 0x5b,
|
||||
0xd1, 0x8a, 0x32, 0x1a, 0xab, 0xd7, 0x5b, 0x27, 0x27, 0x21, 0xe3, 0xde, 0x4e, 0x5f, 0x41, 0xb2,
|
||||
0xba, 0xb9, 0x9e, 0x61, 0x06, 0xc9, 0xfb, 0x72, 0x55, 0x8a, 0x47, 0x5e, 0x5d, 0xcf, 0x97, 0x95,
|
||||
0x60, 0x78, 0x06, 0x7c, 0x51, 0x56, 0xf3, 0x2b, 0xf1, 0xeb, 0x77, 0x3c, 0xfd, 0xc3, 0x80, 0x7f,
|
||||
0xe8, 0x6b, 0xab, 0x8f, 0x0f, 0xce, 0x4e, 0x1f, 0x7c, 0x1f, 0x86, 0x6a, 0xc8, 0x54, 0x70, 0xf8,
|
||||
0x02, 0x32, 0x7f, 0xfa, 0xdb, 0xa8, 0x8a, 0x58, 0x1d, 0x7d, 0x28, 0x32, 0xa1, 0x5f, 0x09, 0x45,
|
||||
0x52, 0x39, 0xfc, 0xb4, 0x1c, 0x7f, 0x9a, 0x46, 0xa6, 0x79, 0x5c, 0x70, 0x15, 0xdc, 0xf4, 0xe6,
|
||||
0xbf, 0xd8, 0x23, 0x88, 0xd5, 0xec, 0xb3, 0x60, 0x5e, 0x94, 0x57, 0x1f, 0x45, 0x74, 0xfc, 0x23,
|
||||
0x31, 0xa9, 0x4f, 0xcb, 0x4a, 0x24, 0x7b, 0xaa, 0x12, 0x1c, 0x01, 0x52, 0x35, 0xab, 0x3c, 0x98,
|
||||
0xe2, 0x04, 0x32, 0xaf, 0xab, 0x72, 0xbe, 0x14, 0xa3, 0xcb, 0xc9, 0x17, 0xd8, 0x98, 0xae, 0x75,
|
||||
0xdb, 0xae, 0xd3, 0xdf, 0xee, 0x52, 0xfa, 0x18, 0xde, 0xfd, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x4e,
|
||||
0xfd, 0x1d, 0x91, 0x8b, 0x02, 0x00, 0x00,
|
||||
// 448 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0xcb, 0x8e, 0xd3, 0x30,
|
||||
0x14, 0xc5, 0x79, 0xb4, 0xcd, 0x6d, 0x67, 0xe4, 0x31, 0x0f, 0x59, 0x2c, 0x50, 0x14, 0x09, 0x91,
|
||||
0x0d, 0xb3, 0x18, 0x24, 0x58, 0x77, 0x3a, 0xa5, 0x1a, 0x41, 0x1f, 0xb8, 0x65, 0x01, 0x9b, 0x2a,
|
||||
0x33, 0xf1, 0x44, 0x16, 0xe3, 0xb4, 0x4a, 0x5c, 0x41, 0xf9, 0x27, 0x3e, 0x81, 0x6f, 0xe0, 0x8f,
|
||||
0x10, 0xf2, 0xad, 0x93, 0x22, 0xc1, 0xca, 0xe7, 0xdc, 0x7b, 0xe4, 0x73, 0x7d, 0x7c, 0x21, 0xd2,
|
||||
0x75, 0x71, 0xbe, 0xad, 0x36, 0x66, 0x93, 0xfc, 0xf6, 0x20, 0x9c, 0xee, 0xa7, 0x75, 0xc1, 0x4e,
|
||||
0xc1, 0x53, 0x39, 0x27, 0x31, 0x49, 0x23, 0xe1, 0xa9, 0x9c, 0x31, 0x08, 0xcc, 0x7e, 0x2b, 0xb9,
|
||||
0x17, 0x93, 0x34, 0x14, 0x88, 0xd9, 0x13, 0xe8, 0x98, 0xac, 0x2a, 0xa4, 0xe1, 0x3e, 0xea, 0x1c,
|
||||
0xb3, 0xda, 0x3c, 0x33, 0x19, 0x0f, 0x62, 0x92, 0x0e, 0x04, 0x62, 0xab, 0xad, 0xd0, 0x83, 0x87,
|
||||
0x31, 0x49, 0xcf, 0x84, 0x63, 0xec, 0x11, 0x84, 0x3a, 0x2b, 0xd4, 0x2d, 0xef, 0x60, 0xf9, 0x40,
|
||||
0x18, 0x05, 0x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
||||
0xc7, 0xd4, 0x4f, 0x7e, 0x11, 0x08, 0xd1, 0xee, 0xbf, 0x56, 0xf6, 0xcb, 0xf0, 0x79, 0x68, 0xd6,
|
||||
0x13, 0x8e, 0xb1, 0xa7, 0xd0, 0xb3, 0xa7, 0x7d, 0x1b, 0x7e, 0xbc, 0x2f, 0x5a, 0xee, 0xd6, 0x26,
|
||||
0xc0, 0x5b, 0xec, 0xda, 0x3c, 0x73, 0xe3, 0xda, 0x4f, 0xef, 0x5f, 0xc0, 0x79, 0xfb, 0xb8, 0xe3,
|
||||
0x5a, 0xd8, 0x53, 0xe5, 0xbc, 0x13, 0xfb, 0x69, 0x28, 0x1c, 0x4b, 0x5e, 0xff, 0x13, 0x58, 0x17,
|
||||
0x7c, 0x31, 0xfe, 0x40, 0x89, 0x05, 0xc3, 0xd1, 0x3b, 0xea, 0xb5, 0x11, 0xfa, 0x88, 0xe6, 0xb3,
|
||||
0x09, 0x0d, 0x2e, 0x07, 0x9f, 0x61, 0xab, 0xca, 0xc2, 0xec, 0xca, 0x52, 0xde, 0xdf, 0x74, 0x70,
|
||||
0xc7, 0x5e, 0xfd, 0x09, 0x00, 0x00, 0xff, 0xff, 0xbe, 0x98, 0x97, 0x18, 0xe2, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
16
msg.proto
16
msg.proto
@ -22,6 +22,17 @@ message MyMsg {
|
||||
int32 timeout = 12;
|
||||
}
|
||||
|
||||
message FrameData {
|
||||
enum TYPE {
|
||||
USER_DATA = 0;
|
||||
CONN = 1;
|
||||
CONNRSP = 2;
|
||||
CLOSE = 3;
|
||||
}
|
||||
int32 type = 1;
|
||||
bytes data = 2;
|
||||
}
|
||||
|
||||
message Frame {
|
||||
enum TYPE {
|
||||
DATA = 0;
|
||||
@ -29,15 +40,12 @@ message Frame {
|
||||
ACK = 2;
|
||||
PING = 3;
|
||||
PONG = 4;
|
||||
REG = 5;
|
||||
REGACK = 6;
|
||||
REGAGAIN = 7;
|
||||
}
|
||||
|
||||
int32 type = 1;
|
||||
bool resend = 2;
|
||||
int64 sendtime = 3;
|
||||
int32 id = 4;
|
||||
bytes data = 5;
|
||||
FrameData data = 5;
|
||||
repeated int32 dataid = 6;
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ func (p *Server) RecvTCP(conn *ServerConn, id string, src *net.IPAddr) {
|
||||
loggo.Info("start wait remote connect tcp %s %s", conn.id, conn.tcpaddrTarget.String())
|
||||
startConnectTime := time.Now()
|
||||
for {
|
||||
if conn.fm.IsRemoteConnected() {
|
||||
if conn.fm.IsConnected() {
|
||||
break
|
||||
}
|
||||
conn.fm.Update()
|
||||
|
Loading…
Reference in New Issue
Block a user