mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-19 02:44:42 +08:00
优化网络
This commit is contained in:
@@ -23,6 +23,7 @@ func (slf *TcpSocketClient) Connect(addr string) error{
|
||||
}
|
||||
slf.conn = conn
|
||||
|
||||
|
||||
//
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/binary"
|
||||
"github.com/duanhf2012/origin/util"
|
||||
"github.com/duanhf2012/origin/service"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"io"
|
||||
"net"
|
||||
"unsafe"
|
||||
@@ -210,6 +211,20 @@ func (slf *SClient) Send(pack *MsgBasePack){
|
||||
slf.sendPack.Push(pack)
|
||||
}
|
||||
|
||||
|
||||
func (slf *SClient) SendMsg(packtype uint16,message proto.Message) error{
|
||||
var msg MsgBasePack
|
||||
data,err := proto.Marshal(message)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg.Make(packtype,data)
|
||||
slf.sendPack.Push(&msg)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (slf *SClient) onsend(){
|
||||
for {
|
||||
pack := slf.sendPack.Pop()
|
||||
|
||||
Reference in New Issue
Block a user