Compare commits
2 commits
e763978b4a
...
fcb8af9af1
Author | SHA1 | Date | |
---|---|---|---|
fcb8af9af1 | |||
73556d37ec |
2 changed files with 4 additions and 5 deletions
7
pod.py
7
pod.py
|
@ -16,7 +16,7 @@ async def handle_socket_read(socketid, tcpreader, ws):
|
||||||
print(f"New socket: {socketid}. Waiting on recv")
|
print(f"New socket: {socketid}. Waiting on recv")
|
||||||
while True:
|
while True:
|
||||||
data = await tcpreader.read(2024)
|
data = await tcpreader.read(2024)
|
||||||
print(f"TCP@{socketid} Received {len(data)} bytes")
|
#print(f"TCP@{socketid} Received {len(data)} bytes")
|
||||||
if data == b'':
|
if data == b'':
|
||||||
print(f"TCP@{socketid} Connection closed")
|
print(f"TCP@{socketid} Connection closed")
|
||||||
c = conn.WSMsg(socketid, conn.MsgType.DISCONNECT)
|
c = conn.WSMsg(socketid, conn.MsgType.DISCONNECT)
|
||||||
|
@ -24,7 +24,7 @@ async def handle_socket_read(socketid, tcpreader, ws):
|
||||||
break
|
break
|
||||||
|
|
||||||
c = conn.WSMsg(socketid, conn.MsgType.DATA, data)
|
c = conn.WSMsg(socketid, conn.MsgType.DATA, data)
|
||||||
print(f'TCP>WS: {c}')
|
#print(f'TCP>WS: {c}')
|
||||||
await ws.send(c.to_bytes())
|
await ws.send(c.to_bytes())
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -62,9 +62,8 @@ async def handle_ws_incoming(cfg, ws, sockets):
|
||||||
|
|
||||||
elif c.msg == conn.MsgType.DATA:
|
elif c.msg == conn.MsgType.DATA:
|
||||||
tcpreader, tcpwriter = sockets[socketid]
|
tcpreader, tcpwriter = sockets[socketid]
|
||||||
print(f'WS>TCP: {c}')
|
#print(f'WS>TCP: {c}')
|
||||||
tcpwriter.write(c.payload)
|
tcpwriter.write(c.payload)
|
||||||
print('written')
|
|
||||||
|
|
||||||
|
|
||||||
def get_config():
|
def get_config():
|
||||||
|
|
2
proxy.py
2
proxy.py
|
@ -29,7 +29,7 @@ async def handler(websocket):
|
||||||
print(f"Connection closed: {e}")
|
print(f"Connection closed: {e}")
|
||||||
finally:
|
finally:
|
||||||
# Unregister the client
|
# Unregister the client
|
||||||
connected_clients.remove(websocket)
|
connected_clients.get(websocket.request.path, set()).remove(websocket)
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
# Start the WebSocket server
|
# Start the WebSocket server
|
||||||
|
|
Loading…
Reference in a new issue