Exemplo n.º 1
0
 private void TryCreateAndAddNewSpectatorOnServer(SpectatorSettingsRequest mess, SerializationModeFlags mode)
 {
     var ipAddress = Game.NetworkEngine.GetConnection(mess.ConnectionID).RemoteTCPEndPoint.Address;
     var newSpectator = GetSpectator(mess, mode);
     newSpectator.LocalID = mess.SpectatorID;
     var newStats = newSpectator.GetStats();
     if (newStats.IsLoggedIn) Game.WebData.UpdatePilotData(newSpectator, newStats.LoginToken);
     Game.DataEngine.AddPendingRemoteSpectatorOnServer(newSpectator);
 }
Exemplo n.º 2
0
 private void TryCreateAndAddNewSpectatorOnClient(SpectatorSettingsRequest mess, SerializationModeFlags mode)
 {
     var newSpectator = GetSpectator(mess, mode);
     var newStats = newSpectator.GetStats();
     if (newStats.IsLoggedIn) Game.WebData.UpdatePilotData(newSpectator, newStats.LoginToken);
     Game.AddRemoteSpectator(newSpectator);
     newSpectator.ID = mess.SpectatorID;
     newSpectator.ServerRegistration = Spectator.ServerRegistrationType.Yes;
 }
Exemplo n.º 3
0
 private void HandleSpectatorSettingsRequestOnClient(SpectatorSettingsRequest mess)
 {
     var spectatorSerializationMode = SerializationModeFlags.ConstantDataFromServer;
     var spectator = Game.DataEngine.Spectators.FirstOrDefault(
         spec => spec.ID == mess.SpectatorID && spec.ServerRegistration != Spectator.ServerRegistrationType.No);
     if (spectator == null)
         TryCreateAndAddNewSpectatorOnClient(mess, spectatorSerializationMode);
     else if (spectator.IsRemote)
         mess.Read(spectator, spectatorSerializationMode, 0);
 }
Exemplo n.º 4
0
 private void HandleSpectatorSettingsRequestOnServer(SpectatorSettingsRequest mess)
 {
     var clientConn = Game.NetworkEngine.GetGameClientConnection(mess.ConnectionID);
     if (clientConn.ConnectionStatus.State == ConnectionUtils.GameClientStatus.StateType.Dropped) return;
     clientConn.ConnectionStatus.IsRequestingSpawnForArenaID = mess.IsRequestingSpawnForArenaID;
     clientConn.ConnectionStatus.IsReadyToStartArena = mess.IsGameClientReadyToStartArena;
     var serializationMode = SerializationModeFlags.ConstantDataFromClient;
     if (!mess.IsRegisteredToServer)
         TryCreateAndAddNewSpectatorOnServer(mess, serializationMode);
     else
     {
         var spectator = Game.DataEngine.FindSpectator(mess.SpectatorID);
         if (spectator == null || spectator.ConnectionID != mess.ConnectionID)
         {
             // Silently ignoring update of an unknown spectator or
             // a spectator that doesn't live on the client who sent the update.
         }
         else
             mess.Read(spectator, serializationMode, 0);
     }
 }
Exemplo n.º 5
0
 private Spectator GetSpectator(SpectatorSettingsRequest mess, SerializationModeFlags mode)
 {
     var ipAddress = Game.NetworkEngine.GetConnection(mess.ConnectionID).RemoteTCPEndPoint.Address;
     Spectator newSpectator;
     switch (mess.Subclass)
     {
         case SpectatorSettingsRequest.SubclassType.Player:
             newSpectator = new Player(Game, "<uninitialised>", CanonicalString.Null, CanonicalString.Null,
                 CanonicalString.Null, mess.ConnectionID, ipAddress);
             break;
         case SpectatorSettingsRequest.SubclassType.BotPlayer:
             newSpectator = new BotPlayer(Game, mess.ConnectionID, ipAddress);
             break;
         default: throw new ApplicationException("Unexpected spectator subclass " + mess.Subclass);
     }
     mess.Read(newSpectator, mode, 0);
     return newSpectator;
 }