From 0f42c181da7c56ca270814442bdebeecb0e38bf6 Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Sat, 1 Jun 2019 10:45:45 +0100 Subject: [PATCH] Various simplifications to examples --- examples/client/asyncio/latency_client.py | 8 +-- examples/client/threads/latency_client.py | 8 +-- examples/server/aiohttp/app.html | 17 +++-- examples/server/aiohttp/app.py | 65 +++++++++--------- examples/server/aiohttp/latency.html | 2 +- examples/server/aiohttp/latency.py | 4 +- examples/server/asgi/app.html | 13 ++-- examples/server/asgi/app.py | 53 +++++++-------- examples/server/asgi/latency.html | 2 +- examples/server/asgi/latency.py | 4 +- examples/server/sanic/app.html | 19 +++--- examples/server/sanic/app.py | 65 +++++++++--------- examples/server/sanic/latency.html | 2 +- examples/server/sanic/latency.py | 4 +- examples/server/tornado/app.py | 66 +++++++++---------- examples/server/tornado/latency.py | 4 +- examples/server/tornado/templates/app.html | 17 +++-- .../server/tornado/templates/latency.html | 2 +- examples/server/wsgi/app.py | 64 +++++++++--------- .../socketio_app/static/index.html | 17 +++-- .../wsgi/django_example/socketio_app/views.py | 63 +++++++++--------- examples/server/wsgi/latency.py | 4 +- examples/server/wsgi/templates/index.html | 17 +++-- examples/server/wsgi/templates/latency.html | 2 +- 24 files changed, 248 insertions(+), 274 deletions(-) diff --git a/examples/client/asyncio/latency_client.py b/examples/client/asyncio/latency_client.py index e8923de..b977a3f 100644 --- a/examples/client/asyncio/latency_client.py +++ b/examples/client/asyncio/latency_client.py @@ -13,14 +13,14 @@ async def send_ping(): await sio.emit('ping_from_client') -@sio.on('connect') -async def on_connect(): +@sio.event +async def connect(): print('connected to server') await send_ping() -@sio.on('pong_from_server') -async def on_pong(data): +@sio.event +async def pong_from_server(data): global start_timer latency = time.time() - start_timer print('latency is {0:.2f} ms'.format(latency * 1000)) diff --git a/examples/client/threads/latency_client.py b/examples/client/threads/latency_client.py index c08b359..a934e48 100644 --- a/examples/client/threads/latency_client.py +++ b/examples/client/threads/latency_client.py @@ -11,14 +11,14 @@ def send_ping(): sio.emit('ping_from_client') -@sio.on('connect') -def on_connect(): +@sio.event +def connect(): print('connected to server') send_ping() -@sio.on('pong_from_server') -def on_pong(data): +@sio.event +def pong_from_server(data): global start_timer latency = time.time() - start_timer print('latency is {0:.2f} ms'.format(latency * 1000)) diff --git a/examples/server/aiohttp/app.html b/examples/server/aiohttp/app.html index d71ebd2..ff896b0 100755 --- a/examples/server/aiohttp/app.html +++ b/examples/server/aiohttp/app.html @@ -6,16 +6,15 @@