/// <summary> /// On disconnect we need to remove the ship from our list of ships within the gameHandler. /// This also means we need to notify clients that the ship has been removed. /// </summary> public void OnDisconnected(string connectionId) { lock (_locker) { try { if (_userHandler.UserExistsAndReady(connectionId)) { User user = _userHandler.GetUser(connectionId); //It's possible for a controller to disconnect without a ship if (!user.Controller) { user.MyShip.Dispose(); user.Connected = false; } else { // Remove me from the ship hosts remote controllers if (user.MyShip != null) { user.MyShip.Host.RemoteControllers.Remove(user); user.MyShip.Host.NotificationManager.Notify("Detached controller."); user.MyShip = null; } _userHandler.RemoveUser(connectionId); } // Leave the leaderboard group just in case user was in it IHubContext context = Game.GetContext(); context.Groups.Remove(connectionId, Leaderboard.LEADERBOARD_REQUESTEE_GROUP); // Clear controllers foreach (User u in user.RemoteControllers) { u.MyShip = null; context.Clients.Client(u.ConnectionID).stopController("Primary account has been stopped!"); } user.RemoteControllers.Clear(); } } catch (Exception e) { ErrorLog.Instance.Log(e); } } }
public void DisconnectUser(User user) { RemoveUser(user.ConnectionID); foreach (User u in user.RemoteControllers) { DisconnectUser(u); } if (user.Connected) { Game.GetContext().Clients.Client(user.ConnectionID).disconnect(); } user.Connected = false; }
public void StopRequestingLeaderboard(string connectionId) { Game.GetContext().Groups.Remove(connectionId, LEADERBOARD_REQUESTEE_GROUP); }
public void RequestLeaderboard(string connectionId) { Game.GetContext().Groups.Add(connectionId, LEADERBOARD_REQUESTEE_GROUP); }