bugfix
This commit is contained in:
parent
8e84ccecce
commit
1a6fbd2423
@ -80,11 +80,18 @@ class XtermProcessor(BaseProcessor):
|
|||||||
self.p_obj.close()
|
self.p_obj.close()
|
||||||
|
|
||||||
async def ws_send(ws:web.WebSocketResponse, data):
|
async def ws_send(ws:web.WebSocketResponse, data):
|
||||||
data = {
|
if not isinstance(data, str):
|
||||||
|
data = json.dumps(data)
|
||||||
|
d = {
|
||||||
"type":1,
|
"type":1,
|
||||||
"data":data
|
"data":data
|
||||||
}
|
}
|
||||||
return await ws.send_str(json.dumps(data))
|
d = json.dumps(d)
|
||||||
|
try:
|
||||||
|
return await ws.send_str(d)
|
||||||
|
except Exception as e:
|
||||||
|
print('ws.send_str() error:', e)
|
||||||
|
return False
|
||||||
|
|
||||||
class WsPool:
|
class WsPool:
|
||||||
def __init__(self, ws, ws_path, app):
|
def __init__(self, ws, ws_path, app):
|
||||||
@ -128,13 +135,9 @@ class WsPool:
|
|||||||
async def sendto(self, data, id=None):
|
async def sendto(self, data, id=None):
|
||||||
if id is None:
|
if id is None:
|
||||||
return await ws_send(self.ws, data)
|
return await ws_send(self.ws, data)
|
||||||
try:
|
|
||||||
d = self.get_data()
|
d = self.get_data()
|
||||||
ws = d.get(id)
|
ws = d.get(id)
|
||||||
return await ws_send(ws, data)
|
return await ws_send(ws, data)
|
||||||
except Exception as e:
|
|
||||||
print('ws.sendto() error:', e)
|
|
||||||
return False
|
|
||||||
|
|
||||||
class WebsocketProcessor(PythonScriptProcessor):
|
class WebsocketProcessor(PythonScriptProcessor):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user