private void ServerController_PlayerChat(ServerController sender, ManiaPlanetPlayerChat methodCall) { ChatInterfaceManager.Get(Configuration.DefaultChat).SendToAll(methodCall.Text, this.ClientsManager.GetClientInfo(methodCall.ClientLogin)); }
private void callEvent(object serverCallback) { var methodCall = XDocument.Parse((string)serverCallback, LoadOptions.None).Root; if (methodCall == null) { return; } var methodNameElement = methodCall.Element("methodName"); if (methodNameElement == null) { return; } //Swith to the right method name and call the event. switch (methodNameElement.Value) { case "ManiaPlanet.PlayerConnect": if (PlayerConnect != null) { var playerConnectCall = new ManiaPlanetPlayerConnect(); if (playerConnectCall.ParseCallXml(methodCall)) { PlayerConnect(this, playerConnectCall); } } break; case "ManiaPlanet.PlayerDisconnect": if (PlayerDisconnect != null) { var playerDisconnectCall = new ManiaPlanetPlayerDisconnect(); if (playerDisconnectCall.ParseCallXml(methodCall)) { PlayerDisconnect(this, playerDisconnectCall); } } break; case "ManiaPlanet.PlayerChat": var playerChatCall = new ManiaPlanetPlayerChat(); if (playerChatCall.ParseCallXml(methodCall)) { if (!playerChatCall.Text.StartsWith("/")) { if (PlayerChat != null) { PlayerChat(this, playerChatCall); } } var potentialCommand = (playerChatCall.Text.TrimStart('/') + " ").ToLowerInvariant(); var command = registeredCommands.Where(cmd => potentialCommand.StartsWith(cmd.Key + " ")); if (command.Any()) { try { command.Single().Value(playerChatCall); } catch //TODO: Specify exception { ChatInterfaceManager.Get(Configuration.DefaultChat).SendToPlayer( "The command [" + playerChatCall.Text.TrimStart('/') + "] was somehow not unique.", ClientsManager.GetClientInfo(playerChatCall.ClientLogin)); } } else { ChatInterfaceManager.Get(Configuration.DefaultChat).SendToPlayer( "The command [" + playerChatCall.Text.TrimStart('/') + "] couldn't be found.", ClientsManager.GetClientInfo(playerChatCall.ClientLogin)); } } break; case "ManiaPlanet.PlayerManialinkPageAnswer": if (PlayerManialinkPageAnswer != null) { var playerManialinkPageAnswerCall = new ManiaPlanetPlayerManialinkPageAnswer(); if (playerManialinkPageAnswerCall.ParseCallXml(methodCall)) { PlayerManialinkPageAnswer(this, playerManialinkPageAnswerCall); } } break; case "ManiaPlanet.Echo": if (Echo != null) { var echoCall = new ManiaPlanetEcho(); if (echoCall.ParseCallXml(methodCall)) { Echo(this, echoCall); } } break; case "ManiaPlanet.ServerStart": if (ServerStart != null) { var serverStartCall = new ManiaPlanetServerStart(); if (serverStartCall.ParseCallXml(methodCall)) { ServerStart(this, serverStartCall); } } break; case "ManiaPlanet.ServerStop": if (ServerStop != null) { var serverStopCall = new ManiaPlanetServerStop(); if (serverStopCall.ParseCallXml(methodCall)) { ServerStop(this, serverStopCall); } } break; case "ManiaPlanet.BeginMatch": if (BeginMatch != null) { var beginMatchCall = new ManiaPlanetBeginMatch(); if (beginMatchCall.ParseCallXml(methodCall)) { BeginMatch(this, beginMatchCall); } } break; case "ManiaPlanet.EndMatch": if (EndMatch != null) { var endMatchCall = new ManiaPlanetEndMatch(); if (endMatchCall.ParseCallXml(methodCall)) { EndMatch(this, endMatchCall); } } break; case "ManiaPlanet.BeginMap": if (BeginMap != null) { var beginMapCall = new ManiaPlanetBeginMap(); if (beginMapCall.ParseCallXml(methodCall)) { BeginMap(this, beginMapCall); } } break; case "ManiaPlanet.EndMap": if (EndMap != null) { var endMapCall = new ManiaPlanetEndMap(); if (endMapCall.ParseCallXml(methodCall)) { EndMap(this, endMapCall); } } break; case "ManiaPlanet.StatusChanged": if (StatusChanged != null) { var statusChangedCall = new ManiaPlanetStatusChanged(); if (statusChangedCall.ParseCallXml(methodCall)) { StatusChanged(this, statusChangedCall); } } break; case "TrackMania.PlayerCheckpoint": Console.WriteLine("Player drove through checkpoint."); if (PlayerCheckpoint != null) { var playerCheckpointCall = new TrackManiaPlayerCheckpoint(); if (playerCheckpointCall.ParseCallXml(methodCall)) { PlayerCheckpoint(this, playerCheckpointCall); } } break; case "TrackMania.PlayerFinish": if (PlayerFinish != null) { var playerFinishCall = new TrackManiaPlayerFinish(); if (playerFinishCall.ParseCallXml(methodCall)) { PlayerFinish(this, playerFinishCall); } } break; case "TrackMania.PlayerIncoherence": if (PlayerIncoherence != null) { var playerIncoherenceCall = new TrackManiaPlayerIncoherence(); if (playerIncoherenceCall.ParseCallXml(methodCall)) { PlayerIncoherence(this, playerIncoherenceCall); } } break; case "ManiaPlanet.BillUpdated": if (BillUpdated != null) { var billUpdatedCall = new ManiaPlanetBillUpdated(); if (billUpdatedCall.ParseCallXml(methodCall)) { BillUpdated(this, billUpdatedCall); } } break; case "ManiaPlanet.TunnelDataReceived": if (TunnelDataReceived != null) { var tunnelDataReceivedCall = new ManiaPlanetTunnelDataReceived(); if (tunnelDataReceivedCall.ParseCallXml(methodCall)) { TunnelDataReceived(this, tunnelDataReceivedCall); } } break; case "ManiaPlanet.MapListModified": if (MapListModified != null) { var mapListModifiedCall = new ManiaPlanetMapListModified(); if (mapListModifiedCall.ParseCallXml(methodCall)) { MapListModified(this, mapListModifiedCall); } } break; case "ManiaPlanet.PlayerInfoChanged": if (PlayerInfoChanged != null) { var playerInfoChangedCall = new ManiaPlanetPlayerInfoChanged(); if (playerInfoChangedCall.ParseCallXml(methodCall)) { PlayerInfoChanged(this, playerInfoChangedCall); } } break; case "ManiaPlanet.VoteUpdated": if (VoteUpdated != null) { var voteUpdatedCall = new ManiaPlanetVoteUpdated(); if (voteUpdatedCall.ParseCallXml(methodCall)) { VoteUpdated(this, voteUpdatedCall); } } break; case "ManiaPlanet.PlayerAlliesChanged": if (PlayerAlliesChanged != null) { var playerAlliesChangedCall = new ManiaPlanetPlayerAlliesChanged(); if (playerAlliesChangedCall.ParseCallXml(methodCall)) { PlayerAlliesChanged(this, playerAlliesChangedCall); } } break; } }