/// <summary> /// 关闭服务 /// </summary> public async Task Close() { // Clear AppId = null; AppKey = null; UserId = null; GameVersion = null; lobbyService = null; Room = null; lobby = null; // 事件解注册 OnLobbyRoomListUpdated = null; OnPlayerRoomJoined = null; OnPlayerRoomLeft = null; OnMasterSwitched = null; OnRoomCustomPropertiesChanged = null; OnRoomSystemPropertiesChanged = null; OnPlayerCustomPropertiesChanged = null; OnPlayerActivityChanged = null; OnCustomEvent = null; OnRoomKicked = null; OnDisconnected = null; OnError = null; if (lobby != null) { await lobby.Close(); } if (Room != null) { await Room.Close(); } }
/// <summary> /// 连接 /// </summary> /// <returns>客户端</returns> public async Task <Client> Connect() { lobbyService = new LobbyService(this); await lobbyService.Authorize(); Logger.Debug("connected at: {0}", Thread.CurrentThread.ManagedThreadId); return(this); }