mirror of
https://github.com/smallevilbeast/ntchat.git
synced 2025-07-07 15:16:06 +08:00
添加微信进程退出通知
This commit is contained in:
parent
0cd080dcaf
commit
594cc561cb
|
@ -1,6 +1,9 @@
|
|||
# 用于接收所有的通知消息
|
||||
MT_ALL = 11000
|
||||
|
||||
# 微信进程退出通知
|
||||
MT_RECV_WECHAT_QUIT_MSG = 11001
|
||||
|
||||
# 第个通知消息,此时已经托管上微信
|
||||
MT_READY_MSG = 11024
|
||||
|
||||
|
|
|
@ -49,8 +49,7 @@ class WeChatMgr(metaclass=Singleton):
|
|||
if client_id not in self.__instance_map:
|
||||
for instance in self.__instance_list:
|
||||
if instance.pid == pid:
|
||||
instance.client_id = client_id
|
||||
instance.status = True
|
||||
instance.bind_client_id(client_id)
|
||||
self.__instance_map[client_id] = instance
|
||||
bind_instance = instance
|
||||
break
|
||||
|
@ -71,5 +70,4 @@ class WeChatMgr(metaclass=Singleton):
|
|||
def __on_close(self, client_id):
|
||||
log.debug("close client_id: %d", client_id)
|
||||
if client_id in self.__instance_map:
|
||||
self.__instance_map[client_id].login_status = False
|
||||
self.__instance_map[client_id].status = False
|
||||
self.__instance_map[client_id].on_close()
|
||||
|
|
|
@ -68,6 +68,15 @@ class WeChat:
|
|||
return f
|
||||
return wrapper
|
||||
|
||||
def on_close(self):
|
||||
self.login_status = False
|
||||
self.status = False
|
||||
self.__msg_event_emitter.emit(str(notify_type.MT_RECV_WECHAT_QUIT_MSG), self)
|
||||
|
||||
def bind_client_id(self, client_id):
|
||||
self.status = True
|
||||
self.client_id = client_id
|
||||
|
||||
def on_recv(self, message):
|
||||
log.debug("on recv message: %s", message)
|
||||
msg_type = message["type"]
|
||||
|
|
Loading…
Reference in New Issue
Block a user