public override bool OnHandleMessage(IMessage message, IServerPeer serverPeer) { Log.DebugFormat("Forwarding Response {0}-{1}", message.Code, message.SubCode); if (message.Parameters.ContainsKey(_serverConfiguration.PeerIdCode)) { Log.DebugFormat("Looking for Peer Id {0}", new Guid((Byte[])message.Parameters[_serverConfiguration.PeerIdCode])); PhotonClientPeer peer = _connectionCollection.GetPeers <PhotonClientPeer>().FirstOrDefault(p => p.PeerId == new Guid((Byte[])message.Parameters[_serverConfiguration.PeerIdCode])); if (peer != null) { Log.DebugFormat("Found Peer"); message.Parameters.Remove(_serverConfiguration.PeerIdCode); _clientCodeRemover.RemoveCodes(message); var response = message as Response; if (response != null) { peer.SendOperationResponse( new OperationResponse(response.Code, response.Parameters) { DebugMessage = response.DebugMessage, ReturnCode = response.ReturnCode }, new SendParameters()); } else { peer.SendOperationResponse(new OperationResponse(message.Code, message.Parameters), new SendParameters()); } } } return(true); }
public bool HandleMessage(IMessage message, IClientPeer peer) { Log.DebugFormat("Received Login Message to Forward"); var messageForwarded = false; // Remove all codes that might attempt to be spoofed by the player CodeRemover.RemoveCodes(message); Log.DebugFormat("Removed codes from message"); // Get a list of all appropriate servers - assume only one login server var loginServers = ConnectionCollection.GetServersByType <IServerPeer>(ServerType.LoginServer); Log.DebugFormat("Found {0} login servers", loginServers.Count); // Add in any other data we need before sending the message - the actual peer id of the client, any other data AddMessageData(message, peer); // Forward the message var login = loginServers.FirstOrDefault(); if (login != null) { login.SendMessage(message); Log.DebugFormat("Forwarded Message to Login Server"); messageForwarded = true; } return(messageForwarded); }
public bool HandleMessage(IMessage message, IServerPeer peer) { // Got a response back from the LoginUserPass - might be successful, might not. if (message.Parameters.ContainsKey(_serverConfiguration.PeerIdCode)) { Log.DebugFormat("Looking for Peer Id {0}", new Guid((Byte[])message.Parameters[_serverConfiguration.PeerIdCode])); IClientPeer clientPeer = _connectionCollection.GetPeers <IClientPeer>().FirstOrDefault(p => p.PeerId == new Guid((Byte[])message.Parameters[_serverConfiguration.PeerIdCode])); if (clientPeer != null) { Log.DebugFormat("Found Peer"); var response = message as Response; // copy our response to a return response Response returnResponse = new Response(Code, SubCode, message.Parameters); // remove any unnecessary codes from the returning packet _clientCodeRemover.RemoveCodes(returnResponse); if (response.ReturnCode == (short)ReturnCode.OK) { // Good response, get the client data and look for the userId to set it for the future. clientPeer.ClientData <CharacterData>().UserId = (int)response.Parameters[(byte)MessageParameterCode.UserId]; } // make one call to send the message back - One "exit point" for the message. clientPeer.SendMessage(response); } } return(true); }
public override bool OnHandleMessage(IMessage message, IServerPeer serverPeer) { Log.DebugFormat("Forwarding Event {0}-{1}", message.Code, message.SubCode); if (message.Parameters.ContainsKey(_serverConfiguration.PeerIdCode)) { Log.DebugFormat("Looking for Peer Id {0}", new Guid((Byte[])message.Parameters[_serverConfiguration.PeerIdCode])); PhotonClientPeer peer = _connectionCollection.GetPeers <PhotonClientPeer>().FirstOrDefault(p => p.PeerId == new Guid((Byte[])message.Parameters[_serverConfiguration.PeerIdCode])); if (peer != null) { message.Parameters.Remove(_serverConfiguration.PeerIdCode); _clientCodeRemover.RemoveCodes(message); peer.SendEvent(new EventData(message.Code, message.Parameters), new SendParameters()); } } return(true); }
public bool HandleMessage(IMessage message, IClientPeer peer) { var messageForwarded = false; var gameServers = connectionCollection.GetServersByType <IServerPeer>(ServerType.GameServer); log.DebugFormat("Received message to the GameServer. Found {0} game servers.", gameServers.Count); codeRemover.RemoveCodes(message); message.Parameters.Add((byte)MessageParameterCode.PeerIdParameterCode, peer.PeerId.ToByteArray()); var gameServer = gameServers.FirstOrDefault(); if (gameServer != null) { gameServer.SendMessage(message); messageForwarded = true; } return(messageForwarded); }