How to use 'python socket disconnect' in Python

Every line of 'python socket disconnect' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
131def on_connect(self, socket):
132 # Called whenever a new connection is accepted.
133 # socket = Source socket.
134 pass
51@sio.on(ROUTES['BACK']['DISCONNECT'])
52async def disconnect(sid):
53
54 if sid in users_socket:
55 user = users_socket[sid]
56 del users_by_user_id[user["id"]]
57 sids_fir_remove = list()
58 try:
59 for user_data in users_socket:
60 if users_socket[user_data]['id'] == user['id']:
61 sids_fir_remove.append(user_data)
62
63 for sid in sids_fir_remove:
64 del users_socket[sid]
65 del sio.environ[sid]
66
67 if user:
68 await sio.emit(ROUTES['FRONT']['USER']['ONLINE'], {
69 'data': [users_by_user_id[user] for user in users_by_user_id]
70 }, namespace='/')
71 except:
72 pass
73
74 return await sio.disconnect(sid)

Related snippets