private void ProcessGameLoaded(NotifyLoadedGamePacket obj) { var result = GetUserSession(obj.SecureToken); if (result != null) { // Tell the game simulator they're good to go var need = result.VerifyGameLoad(obj); if (!need) { return; } // Add the user to the routing table _routingTable.Add(obj.Sender, result); Logger.Instance.Log(Level.Debug, "Session " + result.Session.SessionID + ":" + " A user has succesfully passed their token."); // Assign that user the proper connection foreach (var user in result.Session.Users) { if (user.SecureToken == obj.SecureToken) { user.Connection = obj.Sender; } } } }
private void DoStuff(object sender, EventArgs e) { if (_done) { return; } var packet = new NotifyLoadedGamePacket(_myToken); NetworkManager.Instance.SendPacket(packet); _done = true; }
private ulong FindUser(NotifyLoadedGamePacket obj) { foreach (var user in _simulationState.Entities) { var comp = ((PlayerComponent)user.GetComponent(typeof(PlayerComponent))); if (comp.SecureToken == obj.SecureToken) { comp.Connection = obj.Sender; return(user.ID); } } throw new Exception("A user with the given secure token key could not be found. Sync issue?"); }
/// <summary> /// Verifies a user is okay to enter the game and loading has been complete. /// </summary> /// <returns></returns> public bool VerifyGameLoad(NotifyLoadedGamePacket obj) { if (_secureTokensWaiting.Contains(obj.SecureToken)) { // Verify this player has loaded the game _secureTokensWaiting.Remove(obj.SecureToken); ulong id = FindUser(obj); hasAnyoneLoaded = true; // Once a player has loaded, it's okay to send them them the game state var packet = new SessionSendSimulationStatePacket(_simulationState, id); ClientNetworkManager.Instance.SendPacket(packet, obj.Sender); // The minute we know this entity is good, use it return(true); } return(false); }