Exemple #1
0
def pcsocket_user_online(_redis, _user_uuid, _body):
    _key = REDIS_ONLINE_KEY + ".user_uuid." + _user_uuid
    _listeners = _redis.smembers(_key)
    for _i in _listeners:
        _listener = json.loads(_i)
        _body["device_uuid"] = _listener["device_uuid"]
        async_signal(_listener["host"], _listener["port"], PCSOCKET_SRV.ONLINE, copy.deepcopy(_body))
    return
Exemple #2
0
 def user_typing(self, _user_uuid, _conversation_uuid):
     _key = REDIS_TYPING_KEY + ".user_uuid." + _user_uuid
     _listens = self.redis.smembers(_key)
     for _listen in _listens:
         _listen = json.loads(_listen)
         _d = {
             "typing_user": _user_uuid,
             "typing_conversation": _conversation_uuid,
             "listen_device": _listen["device_uuid"]
         }
         async_signal(_listen["host"], _listen["port"], PCSOCKET_SRV.TYPING, _d)
     return
 def _push_offline_message(self, _user_uuid, _device_uuid):
     _redis = self.application.redis
     _key = PCSocketDeviceData.__tablename__ + ".device_uuid." + _device_uuid
     _pcsocket_uuid = _redis.get(_key)
     if _pcsocket_uuid == None:
         return
     _pcsocket = redis_hash_to_dict(_redis, PCSocketInfo, _pcsocket_uuid)
     if _pcsocket == None:
         return
     _logout = {"device_uuid": _device_uuid, "other_device": self.device.get("uuid")}
     async_signal(_pcsocket["host"], _pcsocket["port"], PCSOCKET_SRV.LOGOUT, _logout)
     logging.info("force logout the same user with multiple devices")
     return
Exemple #4
0
 def ack(self, _code):
     if self._pcsocket == None:
         return
     _host = self._pcsocket.get("host")
     _port = self._pcsocket.get("port")
     _device_uuid = self._pcsocket.get("device_uuid")
     if _host == None or _port == None or _device_uuid == None:
         return
     _body = {
         "device_uuid": _device_uuid,
         "what": DIS_WHAT.SEND,
         "code": _code,
         "extra": {"uuid": self._uuid, "conversation_uuid": self._conversation_uuid},
     }
     async_signal(_host, _port, PCSOCKET_SRV.ACK, _body)
     return
 def _push_offline_message(self, _user_uuid, _device_uuid):
     _redis = self.application.redis
     _key = PCSocketDeviceData.__tablename__ + ".device_uuid." + _device_uuid
     _pcsocket_uuid = _redis.get(_key)
     if _pcsocket_uuid == None:
         return
     _pcsocket = redis_hash_to_dict(_redis, PCSocketInfo, _pcsocket_uuid)
     if _pcsocket == None:
         return
     _logout = {
         "device_uuid": _device_uuid,
         "other_device": self.device.get("uuid")
     }
     async_signal(_pcsocket["host"], _pcsocket["port"], PCSOCKET_SRV.LOGOUT,
                  _logout)
     logging.info("force logout the same user with multiple devices")
     return
Exemple #6
0
 def ack(self, _code):
     if self._pcsocket == None:
         return
     _host = self._pcsocket.get("host")
     _port = self._pcsocket.get("port")
     _device_uuid = self._pcsocket.get("device_uuid")
     if _host == None or _port == None or _device_uuid == None:
         return
     _body = {
         "device_uuid": _device_uuid,
         "what": DIS_WHAT.SEND,
         "code": _code,
         "extra": {
             "uuid": self._uuid,
             "conversation_uuid": self._conversation_uuid
         },
     }
     async_signal(_host, _port, PCSOCKET_SRV.ACK, _body)
     return