public override object GetStatsObject(Spectator spectator) { return new { Name = spectator.Name, LoginToken = spectator.GetStats().LoginToken, Connected = !spectator.IsDisconnected, }; }
private void SpectatorRemovedHandler(Spectator spectator) { if (NetworkMode != NetworkMode.Server) return; Stats.Send(new { RemovePlayer = spectator.GetStats().LoginToken, Name = spectator.Name }); UpdateGameServerInfoToManagementServer(); NetworkEngine.SendToGameClients(new SpectatorOrTeamDeletionMessage { SpectatorOrTeamID = spectator.ID }); }
private void SpectatorAddedHandler(Spectator spectator) { if (NetworkMode == NetworkMode.Server) UpdateGameServerInfoToManagementServer(); spectator.ArenaStatistics.Rating = () => spectator.GetStats().Rating; spectator.ResetForArena(); if (NetworkMode != NetworkMode.Server || spectator.IsLocal) return; var player = spectator as Player; if (player == null) return; player.IsAllowedToCreateShip = () => { if (!player.IsRemote) return false; var arenaID = NetworkEngine.GetGameClientConnection(player.ConnectionID).ConnectionStatus.IsRequestingSpawnForArenaID; if (!arenaID.HasValue || DataEngine.Arena == null) return false; return arenaID.Value == DataEngine.Arena.ID; }; player.Messages.NewChatMessage += mess => SendPlayerMessageToRemoteSpectator(mess, player); player.Messages.NewCombatLogMessage += mess => SendPlayerMessageToRemoteSpectator(mess, player); }
public void ReconnectRemoteSpectatorOnServer(Spectator newSpectator, Spectator oldSpectator) { Log.Write("Reconnecting spectator {0}", oldSpectator.Name); oldSpectator.ReconnectOnServer(newSpectator); Stats.Send(new { AddPlayer = oldSpectator.GetStats().LoginToken, Name = oldSpectator.Name }); }
public void AddRemoteSpectator(Spectator newSpectator) { Log.Write("Adding spectator {0}", newSpectator.Name); DataEngine.Spectators.Add(newSpectator); Stats.Send(new { AddPlayer = newSpectator.GetStats().LoginToken, Name = newSpectator.Name }); }
private void PilotDataRequestDone(IAsyncResult result, Spectator spectator, string requestName) { RequestDone(result, requestName, responseString => { var response = JObject.Parse(responseString); if (response["error"] != null) Log.Write("Error in {0} query: {1}", requestName, response["error"]); spectator.GetStats().Update(response); }); }
public void UpdatePilotRanking(Spectator spectator) { if (spectator.GetStats().PilotId == null) return; var requestPath = string.Format("pilot/id/{0}/rankings", spectator.GetStats().PilotId); RequestFromStats(response => PilotDataRequestDone(response, spectator, "pilot ranking"), requestPath); }
public override string GetStatsString(Spectator spectator) { return spectator.GetStats().LoginToken; }