コード例 #1
0
 def _onDataTransmissionRecv(self, xAsyncTCPClient, data, arg) :
     if arg :
         tot = arg
         uid = data.tobytes()
     else :
         tot, rte = IoTSocketStruct.DecodeDataTRHdr(data)
         if rte :
             self._recv(16, self._onDataTransmissionRecv, tot)
             return
         uid = None
     if tot == IoTSocketStruct.TOT_PING :
         self._send(IoTSocketStruct.MakePongTR())
         self._waitDataTransmission()
     elif tot == IoTSocketStruct.TOT_PONG :
         self._waitDataTransmission()
     elif tot == IoTSocketStruct.TOT_REQUEST :
         self._recv(5, self._onRequestRecv, (uid, ))
     elif tot == IoTSocketStruct.TOT_RESPONSE :
         self._recv(6, self._onResponseRecv, (uid, ))
     elif tot == IoTSocketStruct.TOT_TELTOKEN :
         self._recv(8, self._onTelemetryTokenRecv)
     elif tot == IoTSocketStruct.TOT_CLOSE_CONN :
         self._recv(1, self._onCloseConnCodeRecv)
     else :
         self._send(IoTSocketStruct.MakeCloseConnTR(IoTSocketStruct.CLOSE_CODE_PROTO_ERR))
         self.Close()
コード例 #2
0
 def _onDataTransmissionRecv(self, xAsyncTCPClient, data, arg):
     if arg:
         tot = arg
         uid = data.tobytes()
     else:
         tot, rte = IoTSocketStruct.DecodeDataTRHdr(data)
         if rte:
             self._recv(16, self._onDataTransmissionRecv, tot)
             return
         uid = None
     if tot == IoTSocketStruct.TOT_ACL and self._isCentral:
         self._recv(4, self._onACLItemsCountRecv)
     elif tot == IoTSocketStruct.TOT_PING:
         self._router.Log('SESSION %s > PING RECEIVED' %
                          self._getSessionName())
         self.Send(IoTSocketStruct.MakePongTR())
         self._waitDataTransmission()
     elif tot == IoTSocketStruct.TOT_PONG:
         self._router.Log('SESSION %s > PONG RECEIVED' %
                          self._getSessionName())
         self._waitDataTransmission()
     elif tot == IoTSocketStruct.TOT_REQUEST:
         self._recv(5, self._onRequestRecv, (uid, ))
     elif tot == IoTSocketStruct.TOT_RESPONSE:
         self._recv(6, self._onResponseRecv, (uid, ))
     elif tot == IoTSocketStruct.TOT_CLOSE_CONN:
         self._recv(1, self._onCloseConnCodeRecv)
     else:
         self.Send(
             IoTSocketStruct.MakeCloseConnTR(
                 IoTSocketStruct.CLOSE_CODE_PROTO_ERR))
         self.Close()