diff --git a/Html/apps/sockets/namespaces.py b/Html/apps/sockets/namespaces.py index 171c50e..4b10717 100644 --- a/Html/apps/sockets/namespaces.py +++ b/Html/apps/sockets/namespaces.py @@ -69,6 +69,7 @@ class AgentNamespace(Namespace): folder = request.args.get('folder') print(f'Agent client connected with user_uuid: {user_uuid}, folder: {folder}') join_room(user_uuid, namespace='/agent') + emit('user-connected', {'user_uuid': user_uuid}) def _load_learning_progress(self, chatmanager, user_id, course_id, chapter_name, lesson_name, continue_learn): """加载并恢复用户学习进度 diff --git a/Html/apps/static/js/chatbox.js b/Html/apps/static/js/chatbox.js index 1801818..9116c81 100644 --- a/Html/apps/static/js/chatbox.js +++ b/Html/apps/static/js/chatbox.js @@ -80,10 +80,11 @@ document.addEventListener('DOMContentLoaded', function () { // 初始化聊天消息管理器 chatManager = new ChatMessageManager(); - - socket.on('connect', function () { + socket.on('user-connected', function (data) { console.log('Connected to server'); socket.emit('login',JSON.stringify(data)); + }) + socket.on('connect', function () { }); socket.on('open-iframe', function(data) { OpenIframe();