diff --git a/Html/apps/sockets/namespaces.py b/Html/apps/sockets/namespaces.py index 32b7d44..a1c9b0c 100644 --- a/Html/apps/sockets/namespaces.py +++ b/Html/apps/sockets/namespaces.py @@ -63,12 +63,6 @@ class VSCodeNamespace(Namespace): class AgentNamespace(Namespace): - def on_connect(self): - # 获取前端连接时传递的 query 参数 - user_uuid = request.args.get('user_uuid') - folder = request.args.get('folder') - join_room(user_uuid, namespace='/agent') - emit('user-connected', {'user_uuid': user_uuid}, room=user_uuid,namespace='/agent') def _load_learning_progress(self, chatmanager, user_id, course_id, chapter_name, lesson_name, continue_learn): """加载并恢复用户学习进度 @@ -128,6 +122,7 @@ class AgentNamespace(Namespace): user_id = uuid2username[user_uuid] session['user_uuid'] = user_uuid print(f'User connected with session user_uuid: {user_uuid}') + join_room(user_uuid, namespace='/agent') user_uuid2chatmanager = ex["user_uuid2chatmanager"] user_uuid2ase_client = ex["user_uuid2ase_client"] diff --git a/Html/apps/static/js/chatbox.js b/Html/apps/static/js/chatbox.js index 5640d46..8af54cc 100644 --- a/Html/apps/static/js/chatbox.js +++ b/Html/apps/static/js/chatbox.js @@ -80,11 +80,8 @@ document.addEventListener('DOMContentLoaded', function () { // 初始化聊天消息管理器 chatManager = new ChatMessageManager(); - socket.on('user-connected', function () { - console.log('Connected to server'); - socket.emit('login',JSON.stringify(user_data)); - }) socket.on('connect', function () { + socket.emit('login',JSON.stringify(user_data)); }); socket.on('open-iframe', function() { OpenIframe(user_data);