Пример #1
0
    def OnClose(self, Sender, ConnID, Operation, ErrorCode):
        (ip, port) = HPSocket.HP_Server_GetRemoteAddress(Sender=Sender,
                                                         ConnID=ConnID)
        print('[%d, OnClose] > %s opt=%d err=%d' %
              (ConnID, (ip, port), Operation, ErrorCode))
        try:
            device_id = self.conn_pool.get(ConnID)[2]
            device = Device.objects.get(device_id=device_id)
            device.is_online = False
            device.save()
        except Exception as e:
            print("get device failed")
        try:
            self.conn_pool.pop(ConnID)
        except Exception as e:
            print("pop '{}' failed".format(ConnID))

        return HPSocket.EnHandleResult.HR_OK
Пример #2
0
 def OnClose(self, Sender, ConnID, Operation, ErrorCode):
     (ip, port) = HPSocket.HP_Server_GetRemoteAddress(Sender=Sender,
                                                      ConnID=ConnID)
     print('[%d, OnClose] > %s opt=%d err=%d' %
           (ConnID, (ip, port), Operation, ErrorCode))
     return HPSocket.EnHandleResult.HR_OK
Пример #3
0
 def OnAccept(self, Sender, ConnID, Client):
     (ip, port) = HPSocket.HP_Server_GetRemoteAddress(Sender=Sender,
                                                      ConnID=ConnID)
     print('[%d, OnAccept] < %s' % (ConnID, (ip, port)))
Пример #4
0
 def OnAccept(self, Sender, ConnID, Client):
     (ip, port) = HPSocket.HP_Server_GetRemoteAddress(Sender=Sender,
                                                      ConnID=ConnID)
     print('[%d, OnAccept] < %s' % (ConnID, (ip, port)))
     print('Current connected: %s' %
           repr(HPSocket.HP_Server_GetAllConnectionIDs(Sender)))
Пример #5
0
 def OnAccept(self, Sender, ConnID, Client):
     (ip, port) = HPSocket.HP_Server_GetRemoteAddress(Sender=Sender, ConnID=ConnID)
     print(ConnID, '已接受客户端的请求连接,ip:{},port:{}'.format(ip, port))
Пример #6
0
 def OnClose(self, Sender, ConnID, Operation, ErrorCode):
     (ip, port) = HPSocket.HP_Server_GetRemoteAddress(Sender=Sender, ConnID=ConnID)
     print(ConnID, '客户端已关闭连接,ip:{},port:{}'.format(ip, port))
     return HPSocket.EnHandleResult.HR_OK
Пример #7
0
 def OnAccept(self, Sender, ConnID, Client):
     (ip, port) = HPSocket.HP_Server_GetRemoteAddress(Sender=Sender,
                                                      ConnID=ConnID)
     self.conn_pool.setdefault(ConnID, [ip, port, ""])
     print('[%d, OnAccept] < %s' % (ConnID, (ip, port)))