新增发送原始包接口

This commit is contained in:
boyce
2020-02-12 16:27:15 +08:00
parent f9d6029307
commit 91b5340fd4

View File

@@ -134,6 +134,16 @@ func (slf *TcpSocketServer) SendMsg(clientid uint64,packtype uint16,message pro
return pClient.(*SClient).SendMsg(packtype,message)
}
func (slf *TcpSocketServer) Send(clientid uint64,pack *MsgBasePack) error{
pClient := slf.mapClient.Get(clientid)
if pClient == nil {
return fmt.Errorf("clientid %d is not in connect pool.",clientid)
}
return pClient.(*SClient).Send(pack)
}
func (slf *SClient) listendata(){
defer func() {
slf.Close()
@@ -233,8 +243,14 @@ func (slf *MsgBasePack) Make(packtype uint16,data []byte) {
slf.packsize = uint16(unsafe.Sizeof(slf.packtype)*2)+uint16(len(data))
}
func (slf *SClient) Send(pack *MsgBasePack){
func (slf *SClient) Send(pack *MsgBasePack) error {
if slf.bClose == true {
return fmt.Errorf("client id %d is close!",slf.id)
}
slf.sendPack.Push(pack)
return nil
}
@@ -255,6 +271,8 @@ func (slf *SClient) SendMsg(packtype uint16,message proto.Message) error{
return nil
}
func (slf *SClient) onsend(){
defer func() {
slf.Close()