def handle(self, msg: Message): if IPMSG.IS_CMD_SET(msg.cmd, IPMSG.IPMSG_BR_EXIT): self.removeUser(msg.friend) logger.debug('好友下线:' + msg.friend.__str__()) return True return False
def Execute(self): try: nowTime = time.time() * 1000 if self.before_handler is not None and nowTime < self.deadline: self.before_handler() else: self.afert_handler() except Exception as ex: logger.debug(ex)
def AppendTask(self, task): if self.CollectionLock.acquire(): self.ListTask.append(task) logger.debug('添加任务:%s' % task) self.CollectionLock.release() self.condition.acquire() self.condition.notify() self.condition.release()
def handle(self, msg: Message): if IPMSG.IS_CMD_SET(msg.cmd, IPMSG.IPMSG_GETPUBKEY): strExtra = msg.extra.decode(IPMSG.ENCODETYPE) if strExtra.startswith('21003'): # 回应消息 sender = RepRsaSender() self.sendSender(sender, msg.friend.ip, msg.friend.port) logger.debug('对方请求RSA PUBLIC KEY:' + msg.friend.__str__()) return True return False
def func(): packet.dump() #初步解析数据 msg = Message() msg.friend = User(packet) msg.cmd = packet.cmd msg.extra = packet.extra msg.packno = packet.packno for handler in self.__recvHandler: if handler.handle(msg): break logger.debug('数据报文%d处理完成' % msg.packno)
def handle(self, msg: Message): if IPMSG.IS_CMD_SET(msg.cmd, IPMSG.IPMSG_ANSPUBKEY): strExtra = msg.extra.decode(IPMSG.ENCODETYPE) if strExtra.startswith('21003:'): strE, strN = strExtra[6:].split('-') intE = int(strE, 16) intN = int(strN, 16) SecurtInstance.addPubKey(msg.friend.getId(), intE, intN) #对方发送密钥后需要通知任务队里的任务,设置用户ID类任务全部执行 self.engine.SetReleateTaskRun('PUBKEY_' + msg.friend.getId()) logger.debug('对方发送RSA PUBLIC KEY:' + msg.friend.__str__()) return True return False
def handle(self, msg: Message): if IPMSG.IS_CMD_SET(msg.cmd, IPMSG.IPMSG_BR_ENTRY): strExtra = msg.extra.decode(IPMSG.ENCODETYPE) arrData = strExtra.split(' ') if len(arrData) > 2: msg.friend.nickname = arrData[0] msg.friend.groupname = arrData[1] # 回应消息 sender = CommandSender(IPMSG.IPMSG_ANSENTRY) self.sendSender(sender, msg.friend.ip, msg.friend.port) self.updateUser(msg.friend) logger.debug('好友上线:' + msg.friend.__str__()) return True return False
def handle(self, msg: Message): if IPMSG.IS_CMD_SET(msg.cmd, IPMSG.IPMSG_ANSENTRY) and \ IPMSG.IS_OPT_SET(msg.cmd, IPMSG.FEIQ_EXTEND_CMD): strExtra = msg.extra.decode(IPMSG.ENCODETYPE) arrData = strExtra.split('\0') if len(arrData) >= 2: msg.friend.nickname = arrData[0] msg.friend.groupname = arrData[1] elif len(arrData) >= 1: msg.friend.nickname = arrData[0] #回应消息 #sender = GroupSender(IPMSG.IPMSG_ANSENTRY|IPMSG.FEIQ_EXTEND_CMD) #self.sendSender(sender, msg.friend.ip, msg.friend.port) #self.updateUser(msg.friend) logger.debug('飞秋的分组信息:%s' % (msg.friend, )) return True return False
def thread_func(self): logger.debug('任务线程启动') while not self.StopThread: tk = self.__PeekTask() if tk is not None: tk.Execute() logger.debug('任务执行完成:%s' % (tk.__str__())) elif self.condition.acquire(): #等待一段时间后直接重新开始 self.condition.wait(self.ThreadWaitMs / 1000.0) self.condition.release() logger.debug('线程结束')
def handle(self): logger.debug('Got Msg from ' + str(self.client_address)) packet = UdpPacketData(self.client_address, self.request[0]) Instance.putRecvMessage(packet)
from LogHelp import logger logger.debug('程序启动') from socketserver import UDPServer from SocketHandle import UdpHandle from WorkThread import Instance import socket #from SecurityManager import Security if __name__ == '__main__': #s=Security() UDPSERVER = UDPServer(('', 2425), UdpHandle) UDPSERVER.socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) Instance.startMessage(UDPSERVER.socket.sendto) UDPSERVER.serve_forever()
def handle(self, msg: Message): logger.debug("DebugHandler::%s--->%d--->%s" % (msg.friend.__str__(), msg.cmd, msg.extra.decode(IPMSG.ENCODETYPE))) return False
def func(): logger.debug('开始处理一个发送数据报文') sender.save() #封装数据 addr = (sender.packet.ip, sender.packet.port) self.__socketSend(addr, sender.packet.data)
def handle(self, msg: Message): for item in msg.contents: logger.debug('内容接收结束处理器---->%s' % item) self.engine.onRecvContent(item)
def Execute(self): try: if self.execute_handler is not None: self.execute_handler() except Exception as ex: logger.debug(ex)