dimples 1.2.3__tar.gz → 1.2.4__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.4/LICENSE +21 -0
- dimples-1.2.4/PKG-INFO +31 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/conn/flexible.py +25 -9
- {dimples-1.2.3 → dimples-1.2.4}/dimples/server/session_center.py +56 -28
- {dimples-1.2.3 → dimples-1.2.4}/dimples/utils/log.py +3 -3
- dimples-1.2.4/dimples.egg-info/PKG-INFO +31 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples.egg-info/SOURCES.txt +1 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples.egg-info/entry_points.txt +0 -1
- {dimples-1.2.3 → dimples-1.2.4}/setup.py +1 -1
- dimples-1.2.3/PKG-INFO +0 -22
- dimples-1.2.3/dimples.egg-info/PKG-INFO +0 -22
- {dimples-1.2.3 → dimples-1.2.4}/README.md +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/archivist.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/checkpoint.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/cpu/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/cpu/commands.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/cpu/creator.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/cpu/group.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/cpu/grp_expel.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/cpu/grp_invite.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/cpu/grp_join.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/cpu/grp_query.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/cpu/grp_quit.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/cpu/grp_reset.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/cpu/grp_resign.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/cpu/handshake.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/facebook.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/messenger.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/network/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/network/session.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/network/state.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/network/transition.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/packer.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/processor.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/client/terminal.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/anonymous.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/ans.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/archivist.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/compat/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/compat/btc.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/compat/compatible.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/compat/entity.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/compat/meta.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/compat/network.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/dbi/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/dbi/account.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/dbi/message.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/dbi/session.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/facebook.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/messenger.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/packer.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/processer.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/protocol/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/protocol/ans.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/protocol/block.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/protocol/handshake.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/protocol/login.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/protocol/mute.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/protocol/report.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/register.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/common/session.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/conn/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/conn/gate.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/conn/gatekeeper.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/conn/mars.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/conn/mtp.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/conn/protocol/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/conn/protocol/mars.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/conn/protocol/ws.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/conn/queue.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/conn/seeker.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/conn/session.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/conn/ws.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/account.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/dos/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/dos/base.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/dos/document.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/dos/group.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/dos/group_history.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/dos/group_keys.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/dos/login.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/dos/meta.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/dos/private.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/dos/station.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/dos/user.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/message.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/session.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/t_cipherkey.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/t_document.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/t_group.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/t_group_history.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/t_group_keys.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/t_login.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/t_message.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/t_meta.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/t_private.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/t_station.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/database/t_user.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/edge/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/edge/octopus.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/edge/shared.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/edge/start.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/group/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/group/admin.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/group/builder.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/group/delegate.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/group/emitter.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/group/helper.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/group/manager.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/group/packer.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/register/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/register/base.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/register/ext.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/register/run.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/register/shared.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/server/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/server/archivist.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/server/cpu/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/server/cpu/ans.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/server/cpu/document.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/server/cpu/handshake.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/server/cpu/login.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/server/cpu/report.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/server/dispatcher.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/server/messenger.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/server/packer.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/server/processor.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/server/push.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/server/session.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/server/trace.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/station/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/station/handler.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/station/shared.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/station/start.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/utils/__init__.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/utils/cache.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/utils/config.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples/utils/runner.py +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples.egg-info/dependency_links.txt +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples.egg-info/requires.txt +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/dimples.egg-info/top_level.txt +0 -0
- {dimples-1.2.3 → dimples-1.2.4}/setup.cfg +0 -0
dimples-1.2.4/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.4/PKG-INFO
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: dimples
|
|
3
|
+
Version: 1.2.4
|
|
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.1.1
|
|
20
|
+
Requires-Dist: tcp>=2.1.1
|
|
21
|
+
Requires-Dist: udp>=2.1.1
|
|
22
|
+
Requires-Dist: aiou>=0.1.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
|
|
@@ -36,6 +36,7 @@ from startrek import Connection
|
|
|
36
36
|
from startrek import Arrival, Departure
|
|
37
37
|
from startrek import StarDocker
|
|
38
38
|
|
|
39
|
+
from ..utils import Logging
|
|
39
40
|
from .protocol import DeparturePacker
|
|
40
41
|
|
|
41
42
|
from .ws import WSDocker
|
|
@@ -43,7 +44,7 @@ from .mtp import MTPStreamDocker, TransactionID, MTPHelper
|
|
|
43
44
|
from .mars import MarsStreamDocker, MarsHelper
|
|
44
45
|
|
|
45
46
|
|
|
46
|
-
class FlexibleDocker(StarDocker, DeparturePacker):
|
|
47
|
+
class FlexibleDocker(StarDocker, DeparturePacker, Logging):
|
|
47
48
|
|
|
48
49
|
def __init__(self, remote: SocketAddress, local: Optional[SocketAddress]):
|
|
49
50
|
super().__init__(remote=remote, local=local)
|
|
@@ -61,7 +62,7 @@ class FlexibleDocker(StarDocker, DeparturePacker):
|
|
|
61
62
|
elif MarsStreamDocker.check(data=data):
|
|
62
63
|
docker = MarsStreamDocker(remote=self.remote_address, local=self.local_address)
|
|
63
64
|
else:
|
|
64
|
-
|
|
65
|
+
self.error(msg='unsupported data format: %s' % data)
|
|
65
66
|
return None
|
|
66
67
|
# OK
|
|
67
68
|
docker.delegate = self.delegate
|
|
@@ -74,19 +75,26 @@ class FlexibleDocker(StarDocker, DeparturePacker):
|
|
|
74
75
|
async def set_connection(self, conn: Optional[Connection]):
|
|
75
76
|
await super().set_connection(conn=conn)
|
|
76
77
|
docker = self.__docker
|
|
77
|
-
if docker is
|
|
78
|
+
if docker is None:
|
|
79
|
+
self.error(msg='docker not ready, failed to set connection: %s' % conn)
|
|
80
|
+
else:
|
|
78
81
|
await docker.set_connection(conn=conn)
|
|
79
82
|
|
|
80
83
|
# Override
|
|
81
84
|
async def send_ship(self, ship: Departure) -> bool:
|
|
82
85
|
docker = self.__docker
|
|
83
|
-
if docker is
|
|
86
|
+
if docker is None:
|
|
87
|
+
self.error(msg='docker not ready, failed to send ship: %s' % ship)
|
|
88
|
+
return False
|
|
89
|
+
else:
|
|
84
90
|
return await docker.send_ship(ship=ship)
|
|
85
91
|
|
|
86
92
|
# Override
|
|
87
93
|
async def process_received(self, data: bytes):
|
|
88
94
|
docker = self._get_docker(data=data)
|
|
89
|
-
if docker is
|
|
95
|
+
if docker is None:
|
|
96
|
+
self.error(msg='docker not ready, failed to process received: %s' % data)
|
|
97
|
+
else:
|
|
90
98
|
return await docker.process_received(data=data)
|
|
91
99
|
|
|
92
100
|
# Override
|
|
@@ -113,7 +121,9 @@ class FlexibleDocker(StarDocker, DeparturePacker):
|
|
|
113
121
|
def purge(self, now: float = 0) -> int:
|
|
114
122
|
cnt = super().purge(now=now)
|
|
115
123
|
docker = self.__docker
|
|
116
|
-
if docker is
|
|
124
|
+
if docker is None:
|
|
125
|
+
self.warning(msg='docker not ready, failed to purge')
|
|
126
|
+
else:
|
|
117
127
|
cnt += docker.purge(now=now)
|
|
118
128
|
return cnt
|
|
119
129
|
|
|
@@ -128,14 +138,17 @@ class FlexibleDocker(StarDocker, DeparturePacker):
|
|
|
128
138
|
# Override
|
|
129
139
|
async def process(self) -> bool:
|
|
130
140
|
docker = self.__docker
|
|
131
|
-
if docker is
|
|
141
|
+
if docker is None:
|
|
142
|
+
self.warning(msg='docker not ready, failed to process')
|
|
143
|
+
return False
|
|
144
|
+
else:
|
|
132
145
|
return await docker.process()
|
|
133
146
|
|
|
134
147
|
# Override
|
|
135
148
|
async def send_data(self, payload: Union[bytes, bytearray]) -> bool:
|
|
136
149
|
docker = self.__docker
|
|
137
150
|
if docker is None:
|
|
138
|
-
|
|
151
|
+
self.error(msg='docker not ready, failed to send payload: %s' % payload)
|
|
139
152
|
return False
|
|
140
153
|
elif isinstance(docker, WSDocker):
|
|
141
154
|
ship = docker.pack(payload=payload)
|
|
@@ -156,13 +169,16 @@ class FlexibleDocker(StarDocker, DeparturePacker):
|
|
|
156
169
|
# Override
|
|
157
170
|
async def heartbeat(self):
|
|
158
171
|
docker = self.__docker
|
|
159
|
-
if docker is
|
|
172
|
+
if docker is None:
|
|
173
|
+
self.warning(msg='docker not ready, failed to heart bet')
|
|
174
|
+
else:
|
|
160
175
|
await docker.heartbeat()
|
|
161
176
|
|
|
162
177
|
# Override
|
|
163
178
|
def pack(self, payload: bytes, priority: int = 0) -> Optional[Departure]:
|
|
164
179
|
docker = self.__docker
|
|
165
180
|
if docker is None:
|
|
181
|
+
self.error(msg='docker not ready, failed to pack: %s' % payload)
|
|
166
182
|
return None
|
|
167
183
|
else:
|
|
168
184
|
assert isinstance(docker, DeparturePacker), 'docker error: %s' % docker
|
|
@@ -42,11 +42,12 @@ from typing import Optional, Dict, Set, Tuple
|
|
|
42
42
|
|
|
43
43
|
from dimsdk import ID
|
|
44
44
|
|
|
45
|
+
from ..utils import Logging
|
|
45
46
|
from ..utils import Singleton
|
|
46
47
|
from ..common import Session
|
|
47
48
|
|
|
48
49
|
|
|
49
|
-
class SessionPool:
|
|
50
|
+
class SessionPool(Logging):
|
|
50
51
|
|
|
51
52
|
def __init__(self):
|
|
52
53
|
super().__init__()
|
|
@@ -93,6 +94,31 @@ class SessionPool:
|
|
|
93
94
|
def remove_session(self, remote: Tuple[str, int]):
|
|
94
95
|
self.__sessions.pop(remote, None)
|
|
95
96
|
|
|
97
|
+
def all_sessions(self, identifier: ID) -> Set[Session]:
|
|
98
|
+
all_addresses = self.__addresses.get(identifier)
|
|
99
|
+
if all_addresses is None:
|
|
100
|
+
return set()
|
|
101
|
+
candidates = set()
|
|
102
|
+
clone_addresses = set(all_addresses) # copy
|
|
103
|
+
for remote in clone_addresses:
|
|
104
|
+
session = self.get_session(remote=remote)
|
|
105
|
+
if session is None:
|
|
106
|
+
self.warning(msg='session removed: %s, %s' % (identifier, remote))
|
|
107
|
+
all_addresses.discard(remote)
|
|
108
|
+
self.remove_address(identifier=identifier, remote=remote)
|
|
109
|
+
continue
|
|
110
|
+
elif session.identifier != identifier:
|
|
111
|
+
self.warning(msg='session reused: %s, %s, %s' % (identifier, remote, session))
|
|
112
|
+
all_addresses.discard(remote)
|
|
113
|
+
self.remove_address(identifier=identifier, remote=remote)
|
|
114
|
+
continue
|
|
115
|
+
# got it
|
|
116
|
+
candidates.add(session)
|
|
117
|
+
if len(all_addresses) == 0:
|
|
118
|
+
# remote addresses empty, remote it from cache
|
|
119
|
+
self.__addresses.pop(identifier, None)
|
|
120
|
+
return candidates
|
|
121
|
+
|
|
96
122
|
|
|
97
123
|
@Singleton
|
|
98
124
|
class SessionCenter:
|
|
@@ -107,15 +133,30 @@ class SessionCenter:
|
|
|
107
133
|
with self.__lock:
|
|
108
134
|
return self.__pool.all_users()
|
|
109
135
|
|
|
110
|
-
def get_session(self, remote: Tuple[str, int]) -> Optional[Session]:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
136
|
+
# def get_session(self, remote: Tuple[str, int]) -> Optional[Session]:
|
|
137
|
+
# """ Get session by remote address """
|
|
138
|
+
# with self.__lock:
|
|
139
|
+
# return self.__pool.get_session(remote=remote)
|
|
114
140
|
|
|
115
141
|
def add_session(self, session: Session):
|
|
116
142
|
""" Cache session with remote address """
|
|
117
143
|
with self.__lock:
|
|
144
|
+
remote = session.remote_address
|
|
145
|
+
# check old session
|
|
146
|
+
old = self.__pool.get_session(remote=remote)
|
|
147
|
+
if old is not None:
|
|
148
|
+
# remove old session with remote address
|
|
149
|
+
self.__pool.remove_session(remote=remote)
|
|
150
|
+
# remove remote address with ID if exists
|
|
151
|
+
oid = session.identifier
|
|
152
|
+
if oid is not None:
|
|
153
|
+
self.__pool.remove_address(identifier=oid, remote=remote)
|
|
154
|
+
# add new session
|
|
118
155
|
self.__pool.add_session(session=session)
|
|
156
|
+
if old is not None:
|
|
157
|
+
# set session inactive
|
|
158
|
+
old.set_active(active=False)
|
|
159
|
+
# assert session.identifier is None, 'new session error: %s' % session
|
|
119
160
|
return True
|
|
120
161
|
|
|
121
162
|
def remove_session(self, session: Session):
|
|
@@ -135,16 +176,16 @@ class SessionCenter:
|
|
|
135
176
|
|
|
136
177
|
def update_session(self, session: Session, identifier: ID):
|
|
137
178
|
""" Update ID in this session """
|
|
138
|
-
|
|
139
|
-
if
|
|
179
|
+
oid = session.identifier
|
|
180
|
+
if oid == identifier:
|
|
140
181
|
# nothing changed
|
|
141
182
|
return False
|
|
142
183
|
address = session.remote_address
|
|
143
184
|
assert address is not None, 'session error: %s' % session
|
|
144
185
|
with self.__lock:
|
|
145
|
-
if
|
|
186
|
+
if oid is not None:
|
|
146
187
|
# remove remote address from old ID
|
|
147
|
-
self.__pool.remove_address(identifier=
|
|
188
|
+
self.__pool.remove_address(identifier=oid, remote=address)
|
|
148
189
|
# insert remote address for new ID
|
|
149
190
|
self.__pool.add_address(identifier=identifier, remote=address)
|
|
150
191
|
# update session ID
|
|
@@ -155,30 +196,17 @@ class SessionCenter:
|
|
|
155
196
|
""" Get all active sessions with user ID """
|
|
156
197
|
actives: Set[Session] = set()
|
|
157
198
|
with self.__lock:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
for address in all_addresses:
|
|
162
|
-
# get session by each address
|
|
163
|
-
session = self.__pool.get_session(remote=address)
|
|
164
|
-
if session is None:
|
|
165
|
-
# session gone, discard this address
|
|
166
|
-
discarded.add(address)
|
|
167
|
-
elif session.active:
|
|
199
|
+
all_sessions = self.__pool.all_sessions(identifier=identifier)
|
|
200
|
+
for session in all_sessions:
|
|
201
|
+
if session.active:
|
|
168
202
|
actives.add(session)
|
|
169
|
-
# remove discarded addresses
|
|
170
|
-
for address in discarded:
|
|
171
|
-
all_addresses.discard(address)
|
|
172
203
|
return actives
|
|
173
204
|
|
|
174
205
|
def is_active(self, identifier: ID) -> bool:
|
|
175
206
|
""" check whether user online """
|
|
176
207
|
with self.__lock:
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
# get session by each address
|
|
181
|
-
session = self.__pool.get_session(remote=address)
|
|
182
|
-
if session is not None and session.active:
|
|
208
|
+
all_sessions = self.__pool.all_sessions(identifier=identifier)
|
|
209
|
+
for session in all_sessions:
|
|
210
|
+
if session.active:
|
|
183
211
|
# got one active
|
|
184
212
|
return True
|
|
@@ -43,9 +43,9 @@ ERROR_FLAG = 0x08
|
|
|
43
43
|
|
|
44
44
|
class Log:
|
|
45
45
|
|
|
46
|
-
DEBUG = 0xFF # debug(), info(), warning(), error()
|
|
47
|
-
DEVELOP = 0xFE # info(), warning(), error()
|
|
48
|
-
RELEASE = 0xFC # warning(), error()
|
|
46
|
+
DEBUG = 0xFF # 0000 1111 : debug(), info(), warning(), error()
|
|
47
|
+
DEVELOP = 0xFE # 0000 1110 : info(), warning(), error()
|
|
48
|
+
RELEASE = 0xFC # 0000 1100 : warning(), error()
|
|
49
49
|
|
|
50
50
|
LEVEL = RELEASE
|
|
51
51
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: dimples
|
|
3
|
+
Version: 1.2.4
|
|
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.1.1
|
|
20
|
+
Requires-Dist: tcp>=2.1.1
|
|
21
|
+
Requires-Dist: udp>=2.1.1
|
|
22
|
+
Requires-Dist: aiou>=0.1.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.3/PKG-INFO
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: dimples
|
|
3
|
-
Version: 1.2.3
|
|
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.3
|
|
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
|