예제 #1
0
        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 void SendUpdate(IClientPeer instance)
 {
     if (instance != null)
     {
         instance.SendMessage(new Event(20, 1, new Dictionary <byte, object>()));
     }
 }
예제 #3
0
 public void SendUpdate(IClientPeer instance)
 {
     if (instance != null)
     {
         Log.DebugFormat("Send message to peer");
         instance.SendMessage(new Event(20, 1, new Dictionary <byte, object>()));
     }
 }