Skip to content

Commit 1994196

Browse files
committed
Add basic support for bidirectional communication
1 parent 3b3cd51 commit 1994196

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

postgresql2websocket.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ async def websocket_handler(request):
2222
await connection.add_listener(channel, callback_websocket(ws))
2323
try:
2424
async for msg in ws:
25-
pass
25+
async with connection.transaction():
26+
async for record in connection.cursor(msg.data):
27+
asyncio.ensure_future(ws.send_json(dict(record)))
2628
finally:
2729
request.app['websockets'].remove(ws)
2830
return ws

0 commit comments

Comments
 (0)