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.
Files changed (160) hide show
  1. dimples-1.2.7/LICENSE +21 -0
  2. dimples-1.2.7/PKG-INFO +31 -0
  3. {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/flexible.py +0 -3
  4. {dimples-1.2.6 → dimples-1.2.7}/dimples/register/shared.py +2 -2
  5. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/session.py +35 -17
  6. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/session_center.py +3 -3
  7. {dimples-1.2.6 → dimples-1.2.7}/dimples/station/handler.py +4 -16
  8. dimples-1.2.7/dimples.egg-info/PKG-INFO +31 -0
  9. {dimples-1.2.6 → dimples-1.2.7}/dimples.egg-info/SOURCES.txt +1 -0
  10. {dimples-1.2.6 → dimples-1.2.7}/dimples.egg-info/entry_points.txt +0 -1
  11. {dimples-1.2.6 → dimples-1.2.7}/setup.py +1 -1
  12. dimples-1.2.6/PKG-INFO +0 -22
  13. dimples-1.2.6/dimples.egg-info/PKG-INFO +0 -22
  14. {dimples-1.2.6 → dimples-1.2.7}/README.md +0 -0
  15. {dimples-1.2.6 → dimples-1.2.7}/dimples/__init__.py +0 -0
  16. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/__init__.py +0 -0
  17. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/archivist.py +0 -0
  18. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/checkpoint.py +0 -0
  19. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/__init__.py +0 -0
  20. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/commands.py +0 -0
  21. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/creator.py +0 -0
  22. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/group.py +0 -0
  23. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/grp_expel.py +0 -0
  24. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/grp_invite.py +0 -0
  25. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/grp_join.py +0 -0
  26. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/grp_query.py +0 -0
  27. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/grp_quit.py +0 -0
  28. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/grp_reset.py +0 -0
  29. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/grp_resign.py +0 -0
  30. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/cpu/handshake.py +0 -0
  31. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/facebook.py +0 -0
  32. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/messenger.py +0 -0
  33. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/network/__init__.py +0 -0
  34. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/network/session.py +0 -0
  35. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/network/state.py +0 -0
  36. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/network/transition.py +0 -0
  37. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/packer.py +0 -0
  38. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/processor.py +0 -0
  39. {dimples-1.2.6 → dimples-1.2.7}/dimples/client/terminal.py +0 -0
  40. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/__init__.py +0 -0
  41. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/anonymous.py +0 -0
  42. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/ans.py +0 -0
  43. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/archivist.py +0 -0
  44. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/compat/__init__.py +0 -0
  45. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/compat/btc.py +0 -0
  46. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/compat/compatible.py +0 -0
  47. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/compat/entity.py +0 -0
  48. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/compat/meta.py +0 -0
  49. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/compat/network.py +0 -0
  50. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/dbi/__init__.py +0 -0
  51. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/dbi/account.py +0 -0
  52. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/dbi/message.py +0 -0
  53. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/dbi/session.py +0 -0
  54. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/facebook.py +0 -0
  55. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/messenger.py +0 -0
  56. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/packer.py +0 -0
  57. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/processer.py +0 -0
  58. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/protocol/__init__.py +0 -0
  59. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/protocol/ans.py +0 -0
  60. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/protocol/block.py +0 -0
  61. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/protocol/handshake.py +0 -0
  62. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/protocol/login.py +0 -0
  63. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/protocol/mute.py +0 -0
  64. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/protocol/report.py +0 -0
  65. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/register.py +0 -0
  66. {dimples-1.2.6 → dimples-1.2.7}/dimples/common/session.py +0 -0
  67. {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/__init__.py +0 -0
  68. {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/gate.py +0 -0
  69. {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/gatekeeper.py +0 -0
  70. {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/mars.py +0 -0
  71. {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/mtp.py +0 -0
  72. {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/protocol/__init__.py +0 -0
  73. {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/protocol/mars.py +0 -0
  74. {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/protocol/ws.py +0 -0
  75. {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/queue.py +0 -0
  76. {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/seeker.py +0 -0
  77. {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/session.py +0 -0
  78. {dimples-1.2.6 → dimples-1.2.7}/dimples/conn/ws.py +0 -0
  79. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/__init__.py +0 -0
  80. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/account.py +0 -0
  81. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/__init__.py +0 -0
  82. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/base.py +0 -0
  83. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/document.py +0 -0
  84. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/group.py +0 -0
  85. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/group_history.py +0 -0
  86. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/group_keys.py +0 -0
  87. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/login.py +0 -0
  88. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/meta.py +0 -0
  89. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/private.py +0 -0
  90. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/station.py +0 -0
  91. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/dos/user.py +0 -0
  92. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/message.py +0 -0
  93. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/__init__.py +0 -0
  94. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/base.py +0 -0
  95. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/document.py +0 -0
  96. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/group.py +0 -0
  97. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/grp_history.py +0 -0
  98. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/grp_keys.py +0 -0
  99. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/login.py +0 -0
  100. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/message.py +0 -0
  101. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/meta.py +0 -0
  102. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/station.py +0 -0
  103. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/redis/user.py +0 -0
  104. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/session.py +0 -0
  105. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_base.py +0 -0
  106. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_cipherkey.py +0 -0
  107. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_document.py +0 -0
  108. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_group.py +0 -0
  109. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_group_history.py +0 -0
  110. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_group_keys.py +0 -0
  111. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_login.py +0 -0
  112. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_message.py +0 -0
  113. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_meta.py +0 -0
  114. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_private.py +0 -0
  115. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_station.py +0 -0
  116. {dimples-1.2.6 → dimples-1.2.7}/dimples/database/t_user.py +0 -0
  117. {dimples-1.2.6 → dimples-1.2.7}/dimples/edge/__init__.py +0 -0
  118. {dimples-1.2.6 → dimples-1.2.7}/dimples/edge/octopus.py +0 -0
  119. {dimples-1.2.6 → dimples-1.2.7}/dimples/edge/shared.py +0 -0
  120. {dimples-1.2.6 → dimples-1.2.7}/dimples/edge/start.py +0 -0
  121. {dimples-1.2.6 → dimples-1.2.7}/dimples/group/__init__.py +0 -0
  122. {dimples-1.2.6 → dimples-1.2.7}/dimples/group/admin.py +0 -0
  123. {dimples-1.2.6 → dimples-1.2.7}/dimples/group/builder.py +0 -0
  124. {dimples-1.2.6 → dimples-1.2.7}/dimples/group/delegate.py +0 -0
  125. {dimples-1.2.6 → dimples-1.2.7}/dimples/group/emitter.py +0 -0
  126. {dimples-1.2.6 → dimples-1.2.7}/dimples/group/helper.py +0 -0
  127. {dimples-1.2.6 → dimples-1.2.7}/dimples/group/manager.py +0 -0
  128. {dimples-1.2.6 → dimples-1.2.7}/dimples/group/packer.py +0 -0
  129. {dimples-1.2.6 → dimples-1.2.7}/dimples/register/__init__.py +0 -0
  130. {dimples-1.2.6 → dimples-1.2.7}/dimples/register/base.py +0 -0
  131. {dimples-1.2.6 → dimples-1.2.7}/dimples/register/ext.py +0 -0
  132. {dimples-1.2.6 → dimples-1.2.7}/dimples/register/run.py +0 -0
  133. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/__init__.py +0 -0
  134. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/archivist.py +0 -0
  135. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/cpu/__init__.py +0 -0
  136. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/cpu/ans.py +0 -0
  137. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/cpu/document.py +0 -0
  138. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/cpu/handshake.py +0 -0
  139. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/cpu/login.py +0 -0
  140. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/cpu/report.py +0 -0
  141. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/deliver.py +0 -0
  142. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/dis_roamer.py +0 -0
  143. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/dispatcher.py +0 -0
  144. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/messenger.py +0 -0
  145. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/packer.py +0 -0
  146. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/processor.py +0 -0
  147. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/push.py +0 -0
  148. {dimples-1.2.6 → dimples-1.2.7}/dimples/server/trace.py +0 -0
  149. {dimples-1.2.6 → dimples-1.2.7}/dimples/station/__init__.py +0 -0
  150. {dimples-1.2.6 → dimples-1.2.7}/dimples/station/shared.py +0 -0
  151. {dimples-1.2.6 → dimples-1.2.7}/dimples/station/start.py +0 -0
  152. {dimples-1.2.6 → dimples-1.2.7}/dimples/utils/__init__.py +0 -0
  153. {dimples-1.2.6 → dimples-1.2.7}/dimples/utils/cache.py +0 -0
  154. {dimples-1.2.6 → dimples-1.2.7}/dimples/utils/config.py +0 -0
  155. {dimples-1.2.6 → dimples-1.2.7}/dimples/utils/log.py +0 -0
  156. {dimples-1.2.6 → dimples-1.2.7}/dimples/utils/runner.py +0 -0
  157. {dimples-1.2.6 → dimples-1.2.7}/dimples.egg-info/dependency_links.txt +0 -0
  158. {dimples-1.2.6 → dimples-1.2.7}/dimples.egg-info/requires.txt +0 -0
  159. {dimples-1.2.6 → dimples-1.2.7}/dimples.egg-info/top_level.txt +0 -0
  160. {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
+ [![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/dimchat/demo-py/blob/master/LICENSE)
27
+ [![Version](https://img.shields.io/badge/alpha-0.1.0-red.svg)](https://github.com/dimchat/demo-py/wiki)
28
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/dimchat/demo-py/pulls)
29
+ [![Platform](https://img.shields.io/badge/Platform-Python%203-brightgreen.svg)](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._load_cached_messages()
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._load_cached_messages()
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 load_cached_messages(session: ServerSession):
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.get_session(remote=remote)
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
- crt = _start_session(client_address=self.client_address, request=self.request)
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(client_address, request):
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
+ [![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/dimchat/demo-py/blob/master/LICENSE)
27
+ [![Version](https://img.shields.io/badge/alpha-0.1.0-red.svg)](https://github.com/dimchat/demo-py/wiki)
28
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/dimchat/demo-py/pulls)
29
+ [![Platform](https://img.shields.io/badge/Platform-Python%203-brightgreen.svg)](https://github.com/dimchat/demo-py/wiki)
30
+
31
+ Copyright © 2018-2022 Albert Moky
@@ -1,3 +1,4 @@
1
+ LICENSE
1
2
  README.md
2
3
  setup.py
3
4
  dimples/__init__.py
@@ -2,4 +2,3 @@
2
2
  dime = dimples.edge.start:main
3
3
  dimid = dimples.register.run:main
4
4
  dims = dimples.station.start:main
5
-
@@ -14,7 +14,7 @@ import io
14
14
 
15
15
  from setuptools import setup, find_packages
16
16
 
17
- __version__ = '1.2.6'
17
+ __version__ = '1.2.7'
18
18
  __author__ = 'Albert Moky'
19
19
  __contact__ = 'albert.moky@gmail.com'
20
20
 
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
- [![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/dimchat/demo-py/blob/master/LICENSE)
12
- [![Version](https://img.shields.io/badge/alpha-0.1.0-red.svg)](https://github.com/dimchat/demo-py/wiki)
13
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/dimchat/demo-py/pulls)
14
- [![Platform](https://img.shields.io/badge/Platform-Python%203-brightgreen.svg)](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
- [![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/dimchat/demo-py/blob/master/LICENSE)
12
- [![Version](https://img.shields.io/badge/alpha-0.1.0-red.svg)](https://github.com/dimchat/demo-py/wiki)
13
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/dimchat/demo-py/pulls)
14
- [![Platform](https://img.shields.io/badge/Platform-Python%203-brightgreen.svg)](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