fix: 修复聊天系统编译错误
- 修复 WebSocketManager/SocketIOClient 函数缩进错误 - 重命名 is_connected() 避免与 Object 基类冲突 - 修复 tscn 文件多余前导空格 - 修复测试文件 GUT 断言函数调用 - 添加 GUT 测试框架
This commit is contained in:
@@ -134,11 +134,11 @@ func disconnect_from_server() -> void:
|
||||
_connection_state = ConnectionState.DISCONNECTED
|
||||
disconnected.emit(true)
|
||||
|
||||
# 检查是否已连接
|
||||
# 检查 Socket 是否已连接
|
||||
#
|
||||
# 返回值:
|
||||
# bool - 是否已连接
|
||||
func is_connected() -> bool:
|
||||
func is_socket_connected() -> bool:
|
||||
return _connection_state == ConnectionState.CONNECTED
|
||||
|
||||
# ============================================================================
|
||||
@@ -155,7 +155,7 @@ func is_connected() -> bool:
|
||||
# socket_client.emit("login", {"type": "login", "token": "abc123"})
|
||||
# socket_client.emit("chat", {"t": "chat", "content": "Hello", "scope": "local"})
|
||||
func emit(event_name: String, data: Dictionary) -> void:
|
||||
if not is_connected():
|
||||
if not is_socket_connected():
|
||||
push_error("无法发送事件: 未连接到服务器")
|
||||
error_occurred.emit("未连接到服务器")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user