|
@@ -10,7 +10,7 @@ from src.core.datasource import RedisHandler
|
|
|
import json
|
|
|
|
|
|
socketio = SocketIO(app, async_mode='gevent', cors_allowed_origins="*")
|
|
|
-
|
|
|
+logger = app.logger
|
|
|
redis_handler = RedisHandler()
|
|
|
|
|
|
def listen_to_redis():
|
|
@@ -57,16 +57,17 @@ def common_down_cmd(user_id, data):
|
|
|
class MyNamespace(Namespace):
|
|
|
|
|
|
def on_connect(self):
|
|
|
- print('Client connected, ', request.sid)
|
|
|
+ logger.info('Client connected, %s', request.sid)
|
|
|
|
|
|
def on_login(self, msg):
|
|
|
- print('login.Received message: {}, {}', str(msg), request.sid)
|
|
|
+ logger.info('login.Received message: %s, %s', str(msg), request.sid)
|
|
|
user_id = msg.get('userId')
|
|
|
session['user_id'] = user_id
|
|
|
join_room(user_id)
|
|
|
emit('login', request.sid)
|
|
|
|
|
|
def on_heartbeat(self, heartbeat):
|
|
|
+ logger.info('heartbeat received: %s', heartbeat)
|
|
|
pass
|
|
|
|
|
|
def on_OnPrompt(self, event):
|
|
@@ -87,7 +88,7 @@ class MyNamespace(Namespace):
|
|
|
def on_disconnect(self):
|
|
|
user_id = session.get('user_id')
|
|
|
leave_room(user_id)
|
|
|
- print('Client disconnected', user_id)
|
|
|
+ logger.info('Client disconnected %s', user_id)
|
|
|
|
|
|
|
|
|
socketio.on_namespace(MyNamespace('/ws/cs-im'))
|