Ejemplo n.º 1
0
        private PyObject OldHandle(PyObject packet)
        {
            // Check for login packets and just forward them
            if (packet is PyTuple)
            {
                // Those are the first packets, sent by both client and server
                return(packet);
            }
            else if (packet is PyInt)
            {
                // This is only sent by the server
                return(packet);
            }
            else if (packet is PyString)
            {
                // This is only sent by the server
                return(packet);
            }
            else if (packet is PyDict)
            {
                // Packet sent by the client(HandshakeAck)
                // We need to modify it in order to put our own client address, as it isnt the same as the address that the server sends
                PyDict handshake = packet as PyDict;

                PyDict session = handshake.Get("session_init") as PyDict;

                session.Set("address", new PyString(socket.GetAddress()));

                handshake.Set("session_init", session);

                return(handshake);
            }
            else if (packet is PyObjectEx) // Exceptions... just check the type and decide what to do
            {
                PyException exception = new PyException();

                if (exception.Decode(packet) == true) // Ignore the error
                {
                    Log.Debug("Exceptions", "Got exception of type " + exception.exception_type);
                }

                return(packet);
            }
            else // Normal packets
            {
                PyPacket p = new PyPacket();
                if (p.Decode(packet) == false)
                {
                    // Big problem here, we dont know who to send this
                    Log.Error("Client", "Cannot decode PyPacket");
                }
                else
                {
                    return(HandlePyPacket(p));
                }

                return(packet);
            }
        }
Ejemplo n.º 2
0
        public void SendLoginNotification(LoginStatus loginStatus)
        {
            if (loginStatus == LoginStatus.Sucess)
            {
                AuthenticationRsp rsp = new AuthenticationRsp();

                // String "None" marshaled
                byte[] func_marshaled_code = new byte[] { 0x74, 0x04, 0x00, 0x00, 0x00, 0x4E, 0x6F, 0x6E, 0x65 };

                rsp.serverChallenge         = "";
                rsp.func_marshaled_code     = func_marshaled_code;
                rsp.verification            = false;
                rsp.cluster_usercount       = ClientManager.GetClientsCount() + 1; // We're not in the list yet
                rsp.proxy_nodeid            = 1;
                rsp.user_logonqueueposition = 1;
                rsp.challenge_responsehash  = "55087";

                rsp.macho_version = Common.Constants.Game.machoVersion;
                rsp.boot_version  = Common.Constants.Game.version;
                rsp.boot_build    = Common.Constants.Game.build;
                rsp.boot_codename = Common.Constants.Game.codename;
                rsp.boot_region   = Common.Constants.Game.region;

                // Setup session
                session.SetString("address", socket.GetAddress());
                session.SetString("languageID", request.user_languageid);
                session.SetInt("userType", Common.Constants.AccountType.User);
                session.SetInt("userid", accountid);
                session.SetInt("role", role);

                // We should check for a exact number of nodes here when we have the needed infraestructure
                if (NodeManager.nodes.Count > 0)
                {
                    nodeID = NodeManager.GetRandomNode();
                    Send(rsp.Encode());
                }
                else
                {
                    GPSTransportClosed ex = new GPSTransportClosed("AutClusterStarting");
                    Send(ex.Encode());

                    Close();
                }
            }
            else if (loginStatus == LoginStatus.Failed)
            {
                GPSTransportClosed ex = new GPSTransportClosed("LoginAuthFailed");
                Send(ex.Encode());

                Close();
            }
        }