Skip to content

Commit

Permalink
Corrected user session documentation example (Fixes #1170)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Apr 4, 2023
1 parent 6df96fb commit 72dfdc6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,13 @@ The session can also be manipulated with the `session()` context manager::
For the ``asyncio`` server, an asynchronous context manager is used::

@sio.event
def connect(sid, environ):
async def connect(sid, environ):
username = authenticate_user(environ)
async with sio.session(sid) as session:
session['username'] = username

@sio.event
def message(sid, data):
async def message(sid, data):
async with sio.session(sid) as session:
print('message from ', session['username'])

Expand Down

0 comments on commit 72dfdc6

Please sign in to comment.