diff --git a/Html/apps/sockets/namespaces.py b/Html/apps/sockets/namespaces.py
index 75323fa..6a5c2c6 100644
--- a/Html/apps/sockets/namespaces.py
+++ b/Html/apps/sockets/namespaces.py
@@ -63,6 +63,13 @@ class VSCodeNamespace(Namespace):
class AgentNamespace(Namespace):
+ def on_connect(self):
+ # 获取前端连接时传递的 query 参数
+ user_uuid = request.args.get('user_uuid')
+ folder = request.args.get('folder')
+ print(f'Agent client connected with user_uuid: {user_uuid}, folder: {folder}')
+ join_room(user_id, namespace='/agent')
+
def _load_learning_progress(self, chatmanager, user_id, course_id, chapter_name, lesson_name, continue_learn):
"""加载并恢复用户学习进度
@@ -120,7 +127,6 @@ class AgentNamespace(Namespace):
chapter_name = data['chapter_name']
user_id = uuid2username[user_uuid]
session['user_uuid'] = user_uuid
- join_room(user_uuid, namespace='/agent') # 将该用户加入以user_id为名的room
print(f'User connected with session user_uuid: {user_uuid}')
user_uuid2chatmanager = ex["user_uuid2chatmanager"]
@@ -286,4 +292,4 @@ class AgentNamespace(Namespace):
leave_room(uuid, namespace='/agent')
self.app.logger.info("VSCode client disconnected")
- self.app.logger.info(f"Disconnect reason: {str(data)}")
+ self.app.logger.info(f"Disconnect reason: {str(data)}")
\ No newline at end of file
diff --git a/Html/apps/static/js/chatbox.js b/Html/apps/static/js/chatbox.js
index 5e665bb..1801818 100644
--- a/Html/apps/static/js/chatbox.js
+++ b/Html/apps/static/js/chatbox.js
@@ -75,6 +75,8 @@ document.addEventListener('DOMContentLoaded', function () {
folder: data.folder
}
});
+ console.log('Connecting to WebSocket server at wss://${host}/agent');
+ console.log(data);
// 初始化聊天消息管理器
chatManager = new ChatMessageManager();