def onRecv(self, data): sockConnect.onRecv(self, data) self._symmetryConnectMessageBuffer += data self._connectIsLive = True _headSize = symmetryConnectServerHandler._headSize while True: bufferLen = len(self._symmetryConnectMessageBuffer) if bufferLen >= _headSize: symmetryConnectId, dataSize = struct.unpack( "ih", self._symmetryConnectMessageBuffer[:_headSize]) if dataSize >= 0: endIndex = dataSize + _headSize if bufferLen > endIndex: dataMessage = self._symmetryConnectMessageBuffer[ _headSize:endIndex] self._symmetryConnectMessageBuffer = self._symmetryConnectMessageBuffer[ endIndex + 1:] self._onRecvData(symmetryConnectId, dataMessage) else: break else: self._symmetryConnectMessageBuffer = self._symmetryConnectMessageBuffer[ _headSize + 1:] self._onRecvOpt(symmetryConnectId, dataSize) else: break
def onRecv(self, data): sockConnect.onRecv(self, data) self.sendDataToSymmetryConnect(data) self._symmetryPingLenght += len(data) if(self._symmetryPingLenght>1024*100): self._symmetryPingLenght = 0 self.waitSymmetryPingResponse = True self.sendOptToSymmetryConnect(symmetryConnect.optSymmetryPing)
def onRecv(self,data): sockConnect.onRecv(self, data) self._symmetryConnectMessageBuffer += data while True: bufferLen = len(self._symmetryConnectMessageBuffer) _headSize = symmetryConnectServerHandler._headSize if bufferLen >= _headSize: symmetryConnectId,dataSize = struct.unpack("ih",self._symmetryConnectMessageBuffer[:_headSize]) if dataSize>=0: endIndex = dataSize+_headSize if bufferLen > endIndex: dataMessage = self._symmetryConnectMessageBuffer[_headSize:endIndex] self._symmetryConnectMessageBuffer = self._symmetryConnectMessageBuffer[endIndex+1:] self._onRecvData(symmetryConnectId, dataMessage) else: break else: self._symmetryConnectMessageBuffer = self._symmetryConnectMessageBuffer[_headSize+1:] self._onRecvOpt(symmetryConnectId, dataSize) else: break
def onRecv(self, data): sockConnect.onRecv(self, data) self.sendDataToSymmetryConnect(data)