dimples 1.2.6__tar.gz → 1.2.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dimples-1.2.7/LICENSE +21 -0
- dimples-1.2.7/PKG-INFO +31 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/flexible.py +0 -3
- {dimples-1.2.6 → dimples-1.2.7}/dimples/register/shared.py +2 -2
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/session.py +35 -17
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/session_center.py +3 -3
- {dimples-1.2.6 → dimples-1.2.7}/dimples/station/handler.py +4 -16
- dimples-1.2.7/dimples.egg-info/PKG-INFO +31 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples.egg-info/SOURCES.txt +1 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples.egg-info/entry_points.txt +0 -1
- {dimples-1.2.6 → dimples-1.2.7}/setup.py +1 -1
- dimples-1.2.6/PKG-INFO +0 -22
- dimples-1.2.6/dimples.egg-info/PKG-INFO +0 -22
- {dimples-1.2.6 → dimples-1.2.7}/README.md +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/archivist.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/checkpoint.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/commands.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/creator.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/group.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/grp_expel.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/grp_invite.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/grp_join.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/grp_query.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/grp_quit.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/grp_reset.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/grp_resign.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/handshake.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/facebook.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/messenger.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/network/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/network/session.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/network/state.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/network/transition.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/packer.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/processor.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/client/terminal.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/anonymous.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/ans.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/archivist.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/compat/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/compat/btc.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/compat/compatible.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/compat/entity.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/compat/meta.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/compat/network.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/dbi/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/dbi/account.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/dbi/message.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/dbi/session.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/facebook.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/messenger.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/packer.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/processer.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/protocol/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/protocol/ans.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/protocol/block.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/protocol/handshake.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/protocol/login.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/protocol/mute.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/protocol/report.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/register.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/common/session.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/gate.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/gatekeeper.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/mars.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/mtp.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/protocol/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/protocol/mars.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/protocol/ws.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/queue.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/seeker.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/session.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/ws.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/account.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/base.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/document.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/group.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/group_history.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/group_keys.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/login.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/meta.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/private.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/station.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/user.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/message.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/base.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/document.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/group.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/grp_history.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/grp_keys.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/login.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/message.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/meta.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/station.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/user.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/session.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_base.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_cipherkey.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_document.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_group.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_group_history.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_group_keys.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_login.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_message.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_meta.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_private.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_station.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_user.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/edge/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/edge/octopus.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/edge/shared.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/edge/start.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/group/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/group/admin.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/group/builder.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/group/delegate.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/group/emitter.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/group/helper.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/group/manager.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/group/packer.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/register/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/register/base.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/register/ext.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/register/run.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/archivist.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/cpu/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/cpu/ans.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/cpu/document.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/cpu/handshake.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/cpu/login.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/cpu/report.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/deliver.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/dis_roamer.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/dispatcher.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/messenger.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/packer.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/processor.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/push.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/server/trace.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/station/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/station/shared.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/station/start.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/utils/__init__.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/utils/cache.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/utils/config.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/utils/log.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples/utils/runner.py +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples.egg-info/dependency_links.txt +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples.egg-info/requires.txt +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/dimples.egg-info/top_level.txt +0 -0
- {dimples-1.2.6 → dimples-1.2.7}/setup.cfg +0 -0
dimples-1.2.7/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Albert Moky
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
dimples-1.2.7/PKG-INFO
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: dimples
|
|
3
|
+
Version: 1.2.7
|
|
4
|
+
Summary: DIMP Library for Edges and Stations
|
|
5
|
+
Home-page: https://github.com/dimchat/demo-py
|
|
6
|
+
Author: Albert Moky
|
|
7
|
+
Author-email: albert.moky@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: dimplugins>=2.0.0
|
|
15
|
+
Requires-Dist: dimsdk>=2.0.0
|
|
16
|
+
Requires-Dist: dimp>=2.0.0
|
|
17
|
+
Requires-Dist: dkd>=2.0.0
|
|
18
|
+
Requires-Dist: mkm>=2.0.0
|
|
19
|
+
Requires-Dist: startrek>=2.2.0
|
|
20
|
+
Requires-Dist: tcp>=2.2.0
|
|
21
|
+
Requires-Dist: udp>=2.2.0
|
|
22
|
+
Requires-Dist: aiou>=0.3.0
|
|
23
|
+
|
|
24
|
+
# DIMP Library for Edges and Stations (Python version)
|
|
25
|
+
|
|
26
|
+
[](https://github.com/dimchat/demo-py/blob/master/LICENSE)
|
|
27
|
+
[](https://github.com/dimchat/demo-py/wiki)
|
|
28
|
+
[](https://github.com/dimchat/demo-py/pulls)
|
|
29
|
+
[](https://github.com/dimchat/demo-py/wiki)
|
|
30
|
+
|
|
31
|
+
Copyright © 2018-2022 Albert Moky
|
|
@@ -87,9 +87,6 @@ class FlexiblePorter(StarPorter, DeparturePacker, Logging):
|
|
|
87
87
|
coro = docker.set_connection(conn=self.connection)
|
|
88
88
|
Runner.async_task(coro=coro)
|
|
89
89
|
self.__porter = docker
|
|
90
|
-
if isinstance(docker, WSPorter):
|
|
91
|
-
# ignore first handshake package
|
|
92
|
-
return None
|
|
93
90
|
# OK
|
|
94
91
|
return await docker.process_received(data=data)
|
|
95
92
|
|
|
@@ -123,12 +123,12 @@ async def modify(identifier: ID, database: AccountDBI):
|
|
|
123
123
|
# Step 1: create account
|
|
124
124
|
#
|
|
125
125
|
account = create_account(network=network, database=database)
|
|
126
|
-
meta, doc = account.load_info(identifier=identifier)
|
|
126
|
+
meta, doc = await account.load_info(identifier=identifier)
|
|
127
127
|
if isinstance(account, GroupAccount):
|
|
128
128
|
assert isinstance(doc, Bulletin), 'group document error: %s' % doc
|
|
129
129
|
founder = doc.founder
|
|
130
130
|
assert founder is not None, 'founder not found: %s' % doc
|
|
131
|
-
account.load_founder(founder=founder)
|
|
131
|
+
await account.load_founder(founder=founder)
|
|
132
132
|
#
|
|
133
133
|
# Step 2. edit & save
|
|
134
134
|
#
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"""
|
|
37
37
|
|
|
38
38
|
import socket
|
|
39
|
+
import threading
|
|
39
40
|
import traceback
|
|
40
41
|
from typing import Optional, List, Tuple
|
|
41
42
|
|
|
@@ -84,6 +85,7 @@ class ServerSession(BaseSession):
|
|
|
84
85
|
def __init__(self, remote: Tuple[str, int], sock: socket.socket, database: SessionDBI):
|
|
85
86
|
super().__init__(remote=remote, sock=sock, database=database)
|
|
86
87
|
self.__key = generate_session_key()
|
|
88
|
+
self.__loader = OfflineMessageLoader()
|
|
87
89
|
|
|
88
90
|
@property
|
|
89
91
|
def key(self) -> str:
|
|
@@ -100,28 +102,16 @@ class ServerSession(BaseSession):
|
|
|
100
102
|
old = self.identifier
|
|
101
103
|
if super().set_identifier(identifier=identifier):
|
|
102
104
|
session_change_id(session=self, new_id=identifier, old_id=old)
|
|
103
|
-
self.
|
|
105
|
+
self.__loader.load_cached_messages(session=self)
|
|
104
106
|
return True
|
|
105
107
|
|
|
106
108
|
# Override
|
|
107
109
|
def set_active(self, active: bool, when: float = None) -> bool:
|
|
108
110
|
if super().set_active(active=active, when=when):
|
|
109
111
|
session_change_active(session=self, active=active)
|
|
110
|
-
self.
|
|
112
|
+
self.__loader.load_cached_messages(session=self)
|
|
111
113
|
return True
|
|
112
114
|
|
|
113
|
-
def _load_cached_messages(self):
|
|
114
|
-
if self.identifier is None:
|
|
115
|
-
# user not login
|
|
116
|
-
return False
|
|
117
|
-
elif not self.active:
|
|
118
|
-
# session not active
|
|
119
|
-
return False
|
|
120
|
-
# load cached message asynchronously
|
|
121
|
-
coro = load_cached_messages(session=self)
|
|
122
|
-
# Runner.async_task(coro=coro)
|
|
123
|
-
Runner.async_thread(coro=coro).start()
|
|
124
|
-
|
|
125
115
|
#
|
|
126
116
|
# Docker Delegate
|
|
127
117
|
#
|
|
@@ -183,6 +173,36 @@ class ServerSession(BaseSession):
|
|
|
183
173
|
await remove_reliable_message(msg=msg, receiver=receiver, database=db)
|
|
184
174
|
|
|
185
175
|
|
|
176
|
+
class OfflineMessageLoader:
|
|
177
|
+
|
|
178
|
+
def __init__(self):
|
|
179
|
+
super().__init__()
|
|
180
|
+
self.__lock = threading.Lock()
|
|
181
|
+
self.__thread = None
|
|
182
|
+
|
|
183
|
+
def load_cached_messages(self, session: ServerSession):
|
|
184
|
+
identifier = session.identifier
|
|
185
|
+
if identifier is None:
|
|
186
|
+
# user not login
|
|
187
|
+
return False
|
|
188
|
+
elif not session.active:
|
|
189
|
+
# session not active
|
|
190
|
+
return False
|
|
191
|
+
thr: threading.Thread = self.__thread
|
|
192
|
+
if thr is not None and thr.is_alive():
|
|
193
|
+
return False
|
|
194
|
+
with self.__lock:
|
|
195
|
+
thr = self.__thread
|
|
196
|
+
if thr is not None and thr.is_alive():
|
|
197
|
+
return False
|
|
198
|
+
# load cached message asynchronously
|
|
199
|
+
coro = _load_cached_messages(identifier=identifier, session=session)
|
|
200
|
+
thr = Runner.async_thread(coro=coro)
|
|
201
|
+
thr.start()
|
|
202
|
+
self.__thread = thr
|
|
203
|
+
return True
|
|
204
|
+
|
|
205
|
+
|
|
186
206
|
def get_data_packages(ship: Arrival) -> List[bytes]:
|
|
187
207
|
# get payload
|
|
188
208
|
if isinstance(ship, MTPStreamArrival):
|
|
@@ -224,9 +244,7 @@ def session_change_active(session: ServerSession, active: bool):
|
|
|
224
244
|
return True
|
|
225
245
|
|
|
226
246
|
|
|
227
|
-
async def
|
|
228
|
-
identifier = session.identifier
|
|
229
|
-
assert identifier is not None and session.active, 'session error: %s' % session
|
|
247
|
+
async def _load_cached_messages(identifier: ID, session: ServerSession):
|
|
230
248
|
messenger = session.messenger
|
|
231
249
|
db = messenger.database
|
|
232
250
|
limit = ReliableMessageDBI.CACHE_LIMIT
|
|
@@ -101,16 +101,16 @@ class SessionPool(Logging):
|
|
|
101
101
|
candidates = set()
|
|
102
102
|
clone_addresses = set(all_addresses) # copy
|
|
103
103
|
for remote in clone_addresses:
|
|
104
|
-
session = self.
|
|
104
|
+
session = self.__sessions.get(remote)
|
|
105
105
|
if session is None:
|
|
106
106
|
self.warning(msg='session removed: %s, %s' % (identifier, remote))
|
|
107
107
|
all_addresses.discard(remote)
|
|
108
|
-
self.remove_address(identifier=identifier, remote=remote)
|
|
108
|
+
# self.remove_address(identifier=identifier, remote=remote)
|
|
109
109
|
continue
|
|
110
110
|
elif session.identifier != identifier:
|
|
111
111
|
self.warning(msg='session reused: %s, %s, %s' % (identifier, remote, session))
|
|
112
112
|
all_addresses.discard(remote)
|
|
113
|
-
self.remove_address(identifier=identifier, remote=remote)
|
|
113
|
+
# self.remove_address(identifier=identifier, remote=remote)
|
|
114
114
|
continue
|
|
115
115
|
# got it
|
|
116
116
|
candidates.add(session)
|
|
@@ -46,33 +46,21 @@ class RequestHandler(StreamRequestHandler, Logging):
|
|
|
46
46
|
DIM Request Handler
|
|
47
47
|
"""
|
|
48
48
|
|
|
49
|
-
def __del__(self):
|
|
50
|
-
self.info(msg='request removed: %s' % str(self.client_address))
|
|
51
|
-
|
|
52
|
-
# Override
|
|
53
|
-
def setup(self):
|
|
54
|
-
super().setup()
|
|
55
|
-
self.info(msg='request setup: %s' % str(self.client_address))
|
|
56
|
-
|
|
57
|
-
# Override
|
|
58
|
-
def finish(self):
|
|
59
|
-
super().finish()
|
|
60
|
-
self.info(msg='request finished: %s' % str(self.client_address))
|
|
61
|
-
|
|
62
49
|
# Override
|
|
63
50
|
def handle(self):
|
|
64
51
|
super().handle()
|
|
65
52
|
try:
|
|
66
53
|
self.info(msg='session started: %s' % str(self.client_address))
|
|
67
|
-
|
|
68
|
-
Runner.sync_run(main=crt)
|
|
54
|
+
Runner.sync_run(main=_start_session(handler=self))
|
|
69
55
|
self.info(msg='session finished: %s' % str(self.client_address))
|
|
70
56
|
except Exception as error:
|
|
71
57
|
self.error(msg='request handler error: %s' % error)
|
|
72
58
|
traceback.print_exc()
|
|
73
59
|
|
|
74
60
|
|
|
75
|
-
async def _start_session(
|
|
61
|
+
async def _start_session(handler: RequestHandler):
|
|
62
|
+
client_address = handler.client_address
|
|
63
|
+
request = handler.request
|
|
76
64
|
shared = GlobalVariable()
|
|
77
65
|
session = ServerSession(remote=client_address, sock=request, database=shared.sdb)
|
|
78
66
|
messenger = create_messenger(facebook=shared.facebook, database=shared.mdb, session=session)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: dimples
|
|
3
|
+
Version: 1.2.7
|
|
4
|
+
Summary: DIMP Library for Edges and Stations
|
|
5
|
+
Home-page: https://github.com/dimchat/demo-py
|
|
6
|
+
Author: Albert Moky
|
|
7
|
+
Author-email: albert.moky@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: dimplugins>=2.0.0
|
|
15
|
+
Requires-Dist: dimsdk>=2.0.0
|
|
16
|
+
Requires-Dist: dimp>=2.0.0
|
|
17
|
+
Requires-Dist: dkd>=2.0.0
|
|
18
|
+
Requires-Dist: mkm>=2.0.0
|
|
19
|
+
Requires-Dist: startrek>=2.2.0
|
|
20
|
+
Requires-Dist: tcp>=2.2.0
|
|
21
|
+
Requires-Dist: udp>=2.2.0
|
|
22
|
+
Requires-Dist: aiou>=0.3.0
|
|
23
|
+
|
|
24
|
+
# DIMP Library for Edges and Stations (Python version)
|
|
25
|
+
|
|
26
|
+
[](https://github.com/dimchat/demo-py/blob/master/LICENSE)
|
|
27
|
+
[](https://github.com/dimchat/demo-py/wiki)
|
|
28
|
+
[](https://github.com/dimchat/demo-py/pulls)
|
|
29
|
+
[](https://github.com/dimchat/demo-py/wiki)
|
|
30
|
+
|
|
31
|
+
Copyright © 2018-2022 Albert Moky
|
dimples-1.2.6/PKG-INFO
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: dimples
|
|
3
|
-
Version: 1.2.6
|
|
4
|
-
Summary: DIMP Library for Edges and Stations
|
|
5
|
-
Home-page: https://github.com/dimchat/demo-py
|
|
6
|
-
Author: Albert Moky
|
|
7
|
-
Author-email: albert.moky@gmail.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Description: # DIMP Library for Edges and Stations (Python version)
|
|
10
|
-
|
|
11
|
-
[](https://github.com/dimchat/demo-py/blob/master/LICENSE)
|
|
12
|
-
[](https://github.com/dimchat/demo-py/wiki)
|
|
13
|
-
[](https://github.com/dimchat/demo-py/pulls)
|
|
14
|
-
[](https://github.com/dimchat/demo-py/wiki)
|
|
15
|
-
|
|
16
|
-
Copyright © 2018-2022 Albert Moky
|
|
17
|
-
|
|
18
|
-
Platform: UNKNOWN
|
|
19
|
-
Classifier: Programming Language :: Python :: 3
|
|
20
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
21
|
-
Classifier: Operating System :: OS Independent
|
|
22
|
-
Description-Content-Type: text/markdown
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: dimples
|
|
3
|
-
Version: 1.2.6
|
|
4
|
-
Summary: DIMP Library for Edges and Stations
|
|
5
|
-
Home-page: https://github.com/dimchat/demo-py
|
|
6
|
-
Author: Albert Moky
|
|
7
|
-
Author-email: albert.moky@gmail.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Description: # DIMP Library for Edges and Stations (Python version)
|
|
10
|
-
|
|
11
|
-
[](https://github.com/dimchat/demo-py/blob/master/LICENSE)
|
|
12
|
-
[](https://github.com/dimchat/demo-py/wiki)
|
|
13
|
-
[](https://github.com/dimchat/demo-py/pulls)
|
|
14
|
-
[](https://github.com/dimchat/demo-py/wiki)
|
|
15
|
-
|
|
16
|
-
Copyright © 2018-2022 Albert Moky
|
|
17
|
-
|
|
18
|
-
Platform: UNKNOWN
|
|
19
|
-
Classifier: Programming Language :: Python :: 3
|
|
20
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
21
|
-
Classifier: Operating System :: OS Independent
|
|
22
|
-
Description-Content-Type: text/markdown
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|