Skip to content

Commit 87d8a48

Browse files
committed
Updated examples/app.py
1 parent da5974a commit 87d8a48

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

examples/app.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
sio = SocketManager(app=app)
66

77

8-
@app.sio.on('join')
9-
async def handle_join(sid, *args, **kwargs):
10-
await sio.emit('lobby', 'User joined')
8+
@sio.event
9+
async def connect(sid, *args, **kwargs):
10+
print(f"[{sid}] Connected!")
11+
await sio.emit('test', 'Hello world!')
1112

1213

1314
@sio.on('test')
14-
async def test(sid, *args, **kwargs):
15-
await sio.emit('hey', 'joe')
15+
async def test(sid, data, **kwargs):
16+
print(f'[{sid}] Message Received! >> ', data)
1617

1718

1819
if __name__ == '__main__':
@@ -24,4 +25,4 @@ async def test(sid, *args, **kwargs):
2425

2526
import uvicorn
2627

27-
uvicorn.run("examples.app:app", host='0.0.0.0', port=8000)
28+
uvicorn.run("app:app", host='0.0.0.0', port=8000)

0 commit comments

Comments
 (0)