Exemplo n.º 1
0
        protected void MsgLogin(BinaryReader reader)
        {
            var packet = new LoginPacket();

            packet.Unserialize(reader);

            IPacket s;

            if (Server.ValidateLogin(this, packet.UserName, packet.Password, packet.Subscription, packet.CDKey))
            {
                s = new LoginOkPacket
                {
                    SessionId1 = SessionId1,
                    SessionId2 = SessionId2
                };

                if (Server.OnConnect != null)
                {
                    Server.OnConnect(this);
                }
            }
            else
            {
                s = new LoginFailPacket
                {
                    ResultCode = 1
                };

                _disconnect = true;
            }

            var data = CreatePacket(s);

            Socket.BeginSend(data, 0, data.Length, EndSend, true);
        }
Exemplo n.º 2
0
        protected override void MsgLoginFail(BinaryReader reader)
        {
            var packet = new LoginFailPacket();

            packet.Unserialize(reader);

            switch (packet.ResultCode)
            {
            case 7:
            case 13:
            case 14:
                if (RetryCount-- > 0)
                {
                    Thread.Sleep(1500);
                    SendLogin(UserName, Password, 8, 1);
                }
                break;

            case 1:
            case 6:
            case 8:
            case 15:
            case 20:
                Console.WriteLine("The server is currently unavailable. Please try again later.");
                break;

            case 4:
            case 5:
            case 10:
            case 11:
            case 12:
            case 16:
            case 17:
            case 18:
                Console.WriteLine("There is a problem with your account, please contact customer service.");
                break;

            case 2:
            case 3:
                break;

            default:
                Console.WriteLine("Unknow error.");
                break;
            }
        }