This commit is contained in:
yumoqing 2024-04-29 11:21:17 +08:00
parent cf5cd792dc
commit 7eacc6e625

View File

@ -102,10 +102,10 @@ class WsPool:
def is_online(self, userid):
data = self.get_data()
if data.get(userid):
return True
else:
ws = data.get(userid)
if ws is None:
return False
return True
def register(self, id):
self.id = id
@ -143,25 +143,17 @@ class WebsocketProcessor(PythonScriptProcessor):
lenv.update(params)
params_kw = lenv.params_kw
userid = lenv.params_kw.userid or await lenv.get_user()
print(f'{params_kw=}, {userid=} ============')
print(f'{request.path=}1')
del lenv['request']
print(f'{request.path=}1.1')
txt = await self.loadScript(self.real_path)
print(f'{request.path=}2')
ws = web.WebSocketResponse()
print(f'{request.path=}3', ws.closed)
try:
await ws.prepare(request)
except Exception as e:
print('--------except:', e, type(e))
print_exc()
raise e
print(f'{request.path=}4')
ws_pool = WsPool(ws, request.path, request.app)
print(f'{request.path=}5')
async for msg in ws:
print(f'{msg=}')
if msg.type == aiohttp.WSMsgType.TEXT:
if msg.data == 'exit':
break