修改网络底层

This commit is contained in:
duanhf2012
2020-03-13 15:37:49 +08:00
parent 686d88cabc
commit 0d98f77d07
2 changed files with 2 additions and 6 deletions

View File

@@ -19,7 +19,6 @@ type ITcpSocketServerReciver interface {
OnConnected(pClient *SClient) OnConnected(pClient *SClient)
OnDisconnect(pClient *SClient) OnDisconnect(pClient *SClient)
OnRecvMsg(pClient *SClient, pPack *MsgBasePack) OnRecvMsg(pClient *SClient, pPack *MsgBasePack)
VerifyPackType(packtype uint16) bool
} }
@@ -175,7 +174,7 @@ func (slf *SClient) listendata(){
fillsize,bfillRet,fillhead := pack.FillData(buff,buffDataSize) fillsize,bfillRet,fillhead := pack.FillData(buff,buffDataSize)
//提交校验头 //提交校验头
if fillhead == true { if fillhead == true {
if pack.PackSize>slf.tcpserver.MaxRecvPackSize || slf.tcpserver.iReciver.VerifyPackType(pack.PackType) == false { if pack.PackSize>slf.tcpserver.MaxRecvPackSize {
service.GetLogger().Printf(service.LEVER_WARN, "VerifyPackType error clent id %d is disconnect %d,%d",slf.id,pack.PackType, pack.PackSize) service.GetLogger().Printf(service.LEVER_WARN, "VerifyPackType error clent id %d is disconnect %d,%d",slf.id,pack.PackType, pack.PackSize)
return return
} }

View File

@@ -114,10 +114,7 @@ func (slf *TcpSocketPbService) OnDisconnect(pClient *network.SClient){
slf.disconnEvent(pClient.GetId()) slf.disconnEvent(pClient.GetId())
} }
} }
func (slf *TcpSocketPbService) VerifyPackType(packtype uint16) bool{
_,ok := slf.mapMsg[packtype]
return ok
}
func (slf *MsgProcessor) Handle(pClient *network.SClient,pPack *network.MsgBasePack){ func (slf *MsgProcessor) Handle(pClient *network.SClient,pPack *network.MsgBasePack){
if info, ok := slf.mapMsg[pPack.PackType]; ok { if info, ok := slf.mapMsg[pPack.PackType]; ok {