void JoinRoom() { var joinReq = new { roomNo = roomNo, userId = Player.Me.userId, clientInfo = Utils.GetClientInfo(), userInfo = Utils.GetUserInfo() }; Debug.Log("try to join room"); gameSocket.Emit(Messages.JoinRoom, (socket, packet, args) => { string msg = packet.ToString(); Debug.Log("Join Room Response: " + msg); JoinRoomResponse resp = JsonConvert.DeserializeObject <JoinRoomResponse[]>(msg)[0]; if (resp.status != 0) { Debug.LogError("ErrorMessage: " + resp.errorMessage); Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters[Utils.Message_Key] = "该房间不存在"; Scenes.Load("MainPage", parameters); return; } gamePlayController.HandleResponse(resp); timeLeft = retryTimeInterval; DateTime endConnTime = DateTime.Now; double totalMilliSecs = (endConnTime - startConnTime).TotalMilliseconds; Debug.Log("连接和加入房间,使用了" + totalMilliSecs + "ms"); //Debug.Log("Connect"); }, JsonConvert.SerializeObject(joinReq)); }