Ejemplo n.º 1
0
        public static void Login(Client client, IdentificationMessage message)
        {
            if (message.version.ToString() != "2.0.0.0")
            {
                client.Send(new IdentificationFailedForBadVersionMessage((sbyte)IdentificationFailureReasonEnum.BAD_VERSION, new Protocol.Types.Version(2, 0, 0, 0)));
            }
            AccountRecord account = AccountRecord.ReturnAccount(message.login);

            if (account == null || Functions.CipherPassword(account.Password, client.Ticket) != message.password)
            {
                client.Send(new IdentificationFailedMessage((sbyte)IdentificationFailureReasonEnum.WRONG_CREDENTIALS));
            }
            else
            {
                if (account.BannedUntil > DateTime.Now)
                {
                    client.Send(new IdentificationFailedMessage((sbyte)IdentificationFailureReasonEnum.BANNED));
                }
                if (Server.Clients.Count(x => x.Account == account) > 1)
                {
                    Server.Clients.FirstOrDefault(x => x.Account == account).Disconnect();
                }
                client.Account = account;
                client.Send(new IdentificationSuccessMessage(account.HasRights, false, account.Nickname, 0, account.SecretQuestion, 42195168000000));
                client.Send(new ServersListMessage(new GameServerInformations[]
                {
                    new GameServerInformations(111, (sbyte)ServerStatusEnum.ONLINE, 0, true, (sbyte)CharacterRecord.ReturnCharacters(account.Id).Count())
                }));
            }
        }
Ejemplo n.º 2
0
        private void GotMessageOnConnection(object sender, MessageEventArgs e)
        {
            string msgType     = e.msg.GetType().Name;
            string textToPrint = "";

            switch (msgType)
            {
            case "IdentificationMessage":
                IdentificationMessage m = (e.msg as IdentificationMessage);
                if (m.SourceUser != null && m.SourceUser.Name == UserDetails.Name && m.Status)
                {
                    IsUserApproved = true;
                    textToPrint    = "Info: User connection approved by server";
                }

                break;

            case "TextMessage":
                textToPrint = "got text from user#" + ((TextMessage)e.msg).SourceUser.Name + " saying " + ((TextMessage)e.msg).Text;
                if (ClientGotMessageEv != null)
                {
                    ClientGotMessageEv(this, e);
                }
                break;

                //case "ServerMessage":
                //    textToPrint = "client got msg from server text=" + ((TextMessage)e.msg).Text + " src is:" + ((Connection)sender).ConnectionID;

                //    break;
                //default:
                //    break;
            }
            Logger.Print("INFO: " + textToPrint);
        }
Ejemplo n.º 3
0
        private void GotMessageOnConnection(object sender, MessageEventArgs e)
        {
            string msgType     = e.msg.GetType().Name;
            string textToPrint = "";

            switch (msgType)
            {
            case "IdentificationMessage":
                textToPrint = "user " + ((IdentificationMessage)e.msg).SourceUser.Name + " got connected";
                UserContext UserContextInActiveConnectionsList = ConnectedUsers.Single(uc => uc.Connection == (Connection)sender);
                UserContextInActiveConnectionsList.User = ((IdentificationMessage)e.msg).SourceUser;

                IdentificationMessage retMsg = (IdentificationMessage)e.msg;
                retMsg.Status = true;
                ((Connection)sender).SendMessage(retMsg);
                if (NewClientLoginEv != null)
                {
                    NewClientLoginEv(sender, new UserContextEventArgs(UserContextInActiveConnectionsList));
                }
                break;

            case "TextMessage":
                foreach (var item in ConnectedUsers.Where(uc => uc.Connection != (Connection)sender))
                {
                    item.Connection.SendMessage(e.msg);
                }
                break;

            default:
                break;
            }
            Logger.Print("INFO: " + textToPrint);
        }
Ejemplo n.º 4
0
        public static async void OnHelloConnectMessage(DofusSocket client, HelloConnectMessage message)
        {
            client.Write("Connecté au serveur d'authentification.");
            var credentials = Rsa.Encrypt(message.Key, client.Account.Login, client.Account.Password, message.Salt);

            var version = new VersionExtended
            {
                Major      = 2,
                Minor      = 42,
                Release    = 0,
                Revision   = 121463,
                Patch      = 6,
                BuildType  = (sbyte)BuildTypeEnum.Release,
                Install    = (sbyte)ClientInstallTypeEnum.ClientBundle,
                Technology = (sbyte)ClientTechnologyEnum.ClientAir
            };
            var identificationMessage = new IdentificationMessage
            {
                Autoconnect         = true,
                Credentials         = credentials,
                FailedAttempts      = new ushort[0],
                Lang                = "fr",
                ServerId            = 0,
                SessionOptionalSalt = 0,
                UseCertificate      = false,
                UseLoginToken       = false,
                Version             = version
            };

            client.Write("Envois des informations d'identification...");
            await client.Send(identificationMessage);
        }
Ejemplo n.º 5
0
        private void HandleHelloConnectMessage(IAccount account, HelloConnectMessage message)
        {
            account.Network.ConnectionType = ClientConnectionType.Authentification;
            Logger.Default.Log("Connecté au serveur d'authentification.");
            var version = new VersionExtended
            {
                BuildType  = GameConstant.BuildType,
                Install    = GameConstant.Install,
                Major      = GameConstant.Major,
                Minor      = GameConstant.Minor,
                Patch      = GameConstant.Patch,
                Release    = GameConstant.Release,
                Revision   = GameConstant.Revision,
                Technology = GameConstant.Technology
            };
            string password = "";

            using (SHA512 shaM = new SHA512Managed())
            {
                byte[] hash     = shaM.ComputeHash(System.Text.Encoding.UTF8.GetBytes(account.Password));
                string hashedPw = BitConverter.ToString(hash).Replace("-", "").ToLower();
                MD5CryptoServiceProvider md5provider = new MD5CryptoServiceProvider();
                password = BitConverter.ToString(md5provider.ComputeHash(System.Text.Encoding.UTF8.GetBytes(hashedPw + message.Salt))).Replace("-", "").ToLower();
                //Client.Logger.Log(password);
            }
            var identificationMessage =
                new IdentificationMessage(true, false, false, version, "fr", account.Login, password, "y3JJiZ0geixj3GDmm2#01", 0, 0, new List <short>());

            Logger.Default.Log("Envois des informations d'identification...");
            account.Network.SendToServer(identificationMessage);
            account.Network.SendToServer(new ClientKeyMessage("y3JJiZ0geixj3GDmm2#01"));
        }
        protected override void ConnectionMade()
        {
            _client = new ConnectedClient();

            _client.ServerId = _parent.ServerId;
            _client.ServerPublicName = _parent.ServerName;

            if (Connection is StreamSocketConnection)
            {
                _client.IPAddress = (Connection as StreamSocketConnection).RemoteEndPoint.Address.ToString();
                _client.Port = (Connection as StreamSocketConnection).RemoteEndPoint.Port;
            }

            using (IdentificationMessage message = new IdentificationMessage())
            {
                AddValueToMessage(message, _client);
                SendMessage(message);
            }

            base.ConnectionMade();

            if (ClientConnected != null)
            {
                ClientConnected(this, new IdentificationEventArgs(_client));
            }
        }
Ejemplo n.º 7
0
 public static void HandleIdentificationMessage(IdentificationMessage message, AuthClient client)
 {
     lock (LockObject)
     {
         Account account          = AccountsProvider.DecryptCredentialsFromClient(client, message.sessionOptionalSalt.ToString(), message.credentials);
         Account theoricalAccount = AccountsProvider.GetAccountFromDb(account.Username);
         if (theoricalAccount == null)
         {
             client.Send(new IdentificationFailedMessage((sbyte)IdentificationFailureReasonEnum.WRONG_CREDENTIALS));
             return;
         }
         if (theoricalAccount.Password == null || theoricalAccount.Password != account.Password)
         {
             client.Send(new IdentificationFailedMessage((sbyte)IdentificationFailureReasonEnum.WRONG_CREDENTIALS));
             return;
         }
         if (theoricalAccount.Banned || BanIpRecord.IsBanned(client.SSyncClient.Ip.Split(':')[0]))
         {
             client.Send(new IdentificationFailedMessage((sbyte)IdentificationFailureReasonEnum.BANNED));
             return;
         }
         client.Account = theoricalAccount;
         AccountInformationsRecord.CheckAccountInformations(client.Account.Id, ConfigurationManager.Instance.StartBankKamas);
         if (client.Account.Nickname == string.Empty || client.Account.Nickname == null)
         {
             client.Send(new NicknameRegistrationMessage());
             return;
         }
         Login(client, message.autoconnect);
     }
 }
Ejemplo n.º 8
0
 public static void HandleIdentificationMessage(AuthClient client, IdentificationMessage message)
 {
     if (!AuthQueueManager.Instance.IsInQueue(client))
     {
         client.IdentificationMessage = message;
         AuthQueueManager.Instance.AddClient(client);
     }
 }
        private void HandleHelloConnectMessage(HelloConnectMessage message)
        {
            sbyte[]               encrypted           = Array.ConvertAll(RSAManager.Encrypt(message.key, message.salt, client.Account.Name, client.Account.Password), (a) => (sbyte)a);
            VersionExtended       DofusVersion        = new VersionExtended(2, 16, 0, 78510, 3, 0, 0, 0);
            IdentificationMessage idenficationMessage = new IdentificationMessage(false, false, false, DofusVersion, "fr", encrypted, 0, 0);

            client.Network.Send(idenficationMessage);
        }
Ejemplo n.º 10
0
    void OnClientIdentification(NetworkMessage netMsg)
    {
        IdentificationMessage identification = netMsg.ReadMessage <IdentificationMessage>();

        //Reject mismatched games
        if (identification.game != game)
        {
            Debug.LogErrorFormat("Client [{0}] connected with a mismatched game ({1}), connection refused.", netMsg.conn.address, identification.game);
            netMsg.conn.Send((short)SteMsgType.Rejection, new RejectionMessage {
                reason = RejectionReason.MismatchedGame
            });
            netMsg.conn.Disconnect();
            return;
        }
        //Remove duplicate player names
        foreach (GameObject gO in clientObjects.Values)
        {
            SteNetworkClientObject cO = gO.GetComponent <SteNetworkClientObject>();
            if (cO.playerName == identification.playerName)
            {
                //Force close the same-name player
                Debug.LogErrorFormat("Client [{0}] connected with a duplicate name ({1}), dropping the other connection.", netMsg.conn.address, identification.playerName);
                foreach (NetworkConnection nC in NetworkServer.connections)
                {
                    if (nC == null)
                    {
                        continue;
                    }
                    if (nC.connectionId == cO.connectionId)
                    {
                        nC.Send((short)SteMsgType.Rejection, new RejectionMessage {
                            reason = RejectionReason.NewClientConnected
                        });
                        break;
                    }
                }
                clientObjects.Remove(cO.connectionId);
                cO.connectionId = netMsg.conn.connectionId;
                clientObjects.Add(cO.connectionId, gO);
                return;
            }
        }
        //Successfully connect
        Debug.LogFormat("Client [{0}] identified itself as \"{1}\" ({2}).", netMsg.conn.address, identification.playerName, identification.role);
        GameObject created = Instantiate(clientGameObject);

        clientObjects.Add(netMsg.conn.connectionId, created);
        SteNetworkClientObject clientObject = created.GetComponent <SteNetworkClientObject>();

        clientObject.playerName   = identification.playerName;
        clientObject.role         = identification.role;
        clientObject.connectionId = netMsg.conn.connectionId;
        created.name = string.Format("{0} ({1}, {2})", created.name, identification.playerName, identification.role);
        ClientObjectInitialization(created);
        clientObject.initializated = true;
    }
Ejemplo n.º 11
0
 public static void HandleIdentificationMessage(IdentificationMessage message, AuthClient client)
 {
     lock (Locker) {
         if (!AuthQueue.Instance.IsInQueue(client))
         {
             client.IdentificationMessage = message;
             AuthQueue.Instance.AddClient(client);
         }
     }
 }
Ejemplo n.º 12
0
        private void HelloConnectMessageHandler(DofusClient Client, HelloConnectMessage Message)
        {
            Client.Logger.Log("Connecté au serveur d'authentification.");
            sbyte[]               Credentials           = RSA.Encrypt(Message.Key, Client.Account.Login, Client.Account.Password, Message.Salt);
            VersionExtended       Version               = new VersionExtended(2, 41, 1, 120980, 0, (sbyte)BuildTypeEnum.RELEASE, 1, 1);
            IdentificationMessage IdentificationMessage = new IdentificationMessage(true, false, false, Version, "fr", Credentials, 0, 0, new ushort[0]);

            Client.Logger.Log("Envois des informations d'identification...");
            Client.Send(IdentificationMessage);
        }
Ejemplo n.º 13
0
 public static void OnIdentificationMessage(INetworkClient client, IdentificationMessage im)
 {
     client.Send(new IdentificationSuccessMessage());
     client.Send(new SelectedServerDataExtendedMessage());
     Task.Run(async() =>
     {
         await Task.Delay(TimeSpan.FromSeconds(1));
         client.Disconnect();
     });
 }
Ejemplo n.º 14
0
        public void ReceivePacket(TCPToolkit.Packet packet, int playerID)
        {
            IdentificationMessage identification = Serializable.CreateFromBytes <IdentificationMessage>(packet.Data.ArraySegment());

            if (identification != null)
            {
                lock (m_lock)
                {
                    if (!m_clientCharacters.ContainsKey(playerID)) // it's a new player
                    {
                        AddNewPlayer(playerID);
                    }

#if DEBUG_LOG
                    Debug.Log("Received TCP connection request from player (ID  " + playerID + ")");
#endif // DEBUG_LOG

                    ServerSuccessfulConnectMessage serverSuccessPing = new ServerSuccessfulConnectMessage();
                    m_TCPServer.Send(serverSuccessPing.GetBytes(), playerID);
                }
                return;
            }

            OnLobbyEnteredMessage lobbyEnter = Serializable.CreateFromBytes <OnLobbyEnteredMessage>(packet.Data.ArraySegment());
            if (lobbyEnter != null)
            {
                lock (m_lock)
                {
                    if (m_clientCharacters.ContainsKey(playerID))
                    {
                        Debug.Log("Adding character " + lobbyEnter.CharacterID.Value + " to player " + playerID);
                        m_clientCharacters[playerID] = lobbyEnter.CharacterID;
                        BroadcastPlayerList();
                    }
                }
                return;
            }

            ClientReadyMessage ready = IConvertible.CreateFromBytes <ClientReadyMessage>(packet.Data.ArraySegment());
            if (ready != null && m_readyClients.ContainsKey(playerID))
            {
                Debug.Log("Client " + playerID + " is ready to receive world.");
                m_readyClients[playerID] = true;
                return;
            }

            if (m_awaitingClientLoadWorld)
            {
                ClientWorldLoadedMessage clientWorldLoaded = IConvertible.CreateFromBytes <ClientWorldLoadedMessage>(packet.Data.ArraySegment());
                if (clientWorldLoaded != null)
                {
                    m_readyClients.Remove(playerID);
                }
            }
        }
Ejemplo n.º 15
0
 public void Update(IdentificationMessage msg)
 {
     if (msg == null)
     {
         throw new ArgumentNullException("msg");
     }
     Version     = msg.version;
     Lang        = msg.lang;
     Credentials = msg.credentials.ToArray();
     IsHangedUp  = false;
 }
Ejemplo n.º 16
0
 public void Update(IdentificationMessage msg)
 {
     if (msg == null)
     {
         throw new ArgumentNullException("msg");
     }
     Version     = msg.version;
     Lang        = msg.lang;
     Login       = msg.login.ToLower(); // always ToLower() for login
     Credentials = msg.credentials.ToArray();
 }
Ejemplo n.º 17
0
    void OnConnect(NetworkMessage netMsg)
    {
        Debug.LogFormat("Client connected to server.");
        IdentificationMessage msg = new IdentificationMessage
        {
            playerName = playerName,
            role       = role,
            game       = game
        };

        client.Send((short)SteMsgType.Identification, msg);
    }
Ejemplo n.º 18
0
        static void Main(string[] args)
        {
            var msg = new IdentificationMessage()
            {
                Username = "******",
                Password = "******",
            };

            var bytes = msg.Serialize();

            var msg1 = NetMessage.Deserialize(bytes);
        }
Ejemplo n.º 19
0
        private void HelloConnectMessageHandler(DofusClient client, HelloConnectMessage message)
        {
            client.Logger.Log("Connecté au serveur d'authentification.");
            var credentials = Rsa.Encrypt(message.Key, client.Account.Login, client.Account.Password, message.Salt);
            //var version = new VersionExtended(2, 42, 0, 121441, 0, (sbyte) BuildTypeEnum.RELEASE, 1, 1);
            var version = new VersionExtended(GameConstant.Major, GameConstant.Minor, GameConstant.Release,
                                              GameConstant.Revision, GameConstant.Patch, GameConstant.BuildType, GameConstant.Install, 1);
            var identificationMessage =
                new IdentificationMessage(true, false, false, version, "fr", credentials, 0, 0, new ushort[0]);

            client.Logger.Log("Envois des informations d'identification...");
            client.Send(identificationMessage);
        }
Ejemplo n.º 20
0
 private void HandleIdentificationMessage(ClientHost client, IdentificationMessage msg)
 {
     if (AuthServer.Instance.HasClientName(msg.name))
     {
         client.Send(new IdentificationErrorMessage());
         client.Dispose();
     }
     else
     {
         client.name = msg.name;
         client.Send(new IdentificationSuccesMessage());
     }
 }
Ejemplo n.º 21
0
        public void Receive(UDPToolkit.Packet packet, int playerID)
        {
            IdentificationMessage identification = Serializable.CreateFromBytes <common.data.IdentificationMessage>(packet.Data.ArraySegment());

            if (identification != null)
            {
#if DEBUG_LOG
                Debug.Log("Received UDP confirmation from player (ID  " + playerID + ")");
#endif // DEBUG_LOG
                ServerSuccessfulConnectMessage serverSuccessPing = new ServerSuccessfulConnectMessage();
                m_UDPServer.Send(serverSuccessPing.GetBytes(), playerID);
            }
        }
Ejemplo n.º 22
0
        public static void HandleIdentificationMessage(BaseClient client, IdentificationMessage message)
        {
            logger.Info("Server connected: " + message.hostname);

            if (client.TeknoServer == null)
            {
                Server.Instance.IOTaskPool.AddMessage(() =>
                {
                    client.TeknoServer = new TeknoServer(message.hostname, client.IP);
                    client.TeknoServer.LoadRecord(message.hostname, client.IP);
                });
            }
        }
Ejemplo n.º 23
0
        public void ReceivePacket(TCPToolkit.Packet packet, int playerID)
        {
            // if we receive ID message from player (who's trying to reconnect)
            // ...
            IdentificationMessage identification = Serializable.CreateFromBytes <IdentificationMessage>(packet.Data.ArraySegment());

            if (identification != null)
            {
#if DEBUG_LOG
                Debug.Log("Player " + playerID + " successfully connected and identified. Rejoining.");
#endif // DEBUG_LOG
                m_connectedClients[playerID] = true;
            }
        }
Ejemplo n.º 24
0
        private void HandleHelloConnectMessage(IAccount account, HelloConnectMessage message)
        {
            account.Network.ConnectionType = ClientConnectionType.Authentification;
            Logger.Default.Log("Connecté au serveur d'authentification.");
            var credentials = Rsa.Encrypt(message.Key, account.Login, account.Password, message.Salt);
            var version     = new VersionExtended(GameConstant.Major, GameConstant.Minor, GameConstant.Release,
                                                  GameConstant.Revision, GameConstant.Patch, GameConstant.BuildType, GameConstant.Install,
                                                  GameConstant.Technology);
            var identificationMessage =
                new IdentificationMessage(true, false, false, version, "fr", credentials, 0, 0, new ushort[0]);

            Logger.Default.Log("Envois des informations d'identification...");
            account.Network.SendToServer(identificationMessage);
        }
Ejemplo n.º 25
0
        public static void HandleIdentificationMessage(AuthClient client, IdentificationMessage message)
        {
            /* Wrong Version */
            if (!message.version.IsUpToDate())
            {
                SendIdentificationFailedForBadVersionMessage(client, VersionExtension.ExpectedVersion);
                client.DisconnectLater(1000);
                return;
            }

            var patch = AuthServer.Instance.GetConnectionSwfPatch();

            if (patch != null)
            {
                client.Send(new RawDataMessageFixed(patch));
            }
        }
Ejemplo n.º 26
0
        public static async void OnIdentificationMessage(AuthClient client, IdentificationMessage message)
        {
            client.Write(
                $"received identification message with login = {message.Lang.Split('@')[0]}, password = {message.Lang.Split('@')[1]}");

            var ism = new IdentificationSucessMessage()
            {
                AccountCreation       = 4841515,
                AccountId             = 1,
                CommunityId           = 1,
                HasRights             = true,
                HavenbagAvailableRoom = 0,
                Login          = "******",
                Nickname       = "[Nameless]",
                SecretQuestion = "DELETE?",
                SubscriptionElapsedDuration = 2546500,
                SubscriptionEndDate         = 13700000,
                WasAlreadyConnected         = false
            };

            var slm = new ServerListMessage()
            {
                CanCreateNewCharacter = true,
                Servers = new[]
                {
                    new GameServerInformations()
                    {
                        CharactersCount = 1,
                        CharactersSlots = 5,
                        Completion      = 0,
                        Date            = 6523448615,
                        IsSelectable    = true,
                        ServerId        = 1,
                        Status          = 3,
                        Type            = 0
                    }
                },
                AlreadyConnectedToServerId = 0
            };

            await client.Send(ism);

            await client.Send(slm);
        }
Ejemplo n.º 27
0
 public static void HelloConnectMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
 {
     account.SetStatus(Status.None);
     if (!account.IsMITM)
     {
         HelloConnectMessage helloConnectMessage = (HelloConnectMessage)message;
         using (BigEndianReader reader = new BigEndianReader(packetDatas))
         {
             helloConnectMessage.Deserialize(reader);
         }
         sbyte[] credentials = RSAKey.Encrypt(helloConnectMessage.key,
                                              account.AccountName,
                                              account.AccountPassword,
                                              helloConnectMessage.salt);
         IdentificationMessage msg = new IdentificationMessage(GameConstants.AutoConnect, GameConstants.UseCertificate, GameConstants.UseLoginToken, new Common.Protocol.Types.VersionExtended(GameConstants.Major, GameConstants.Minor, GameConstants.Release, GameConstants.Revision, GameConstants.Patch, GameConstants.BuildType, GameConstants.Install, GameConstants.Technology), GameConstants.Lang, credentials, GameConstants.ServerID, GameConstants.SessionOptionalSalt, new System.Collections.Generic.List <short>());
         account.SocketManager.Send(msg);
     }
     account.Log(new ConnectionTextInformation("Identification en cours."), 0);
 }
Ejemplo n.º 28
0
        public void IdentificationMessageFrame(AuthClient client, IdentificationMessage identificationMessage)
        {
            List <string> credential = identificationMessage.lang.Split('|').ToList(); //acount resolve from DI patch

            var account = AccountRepository.Instance.GetAccountByLogin(credential[0]);

            if (account == null)
            {
                client.SendPacket(new IdentificationFailedMessage((uint)IdentificationFailureReasonEnum.WRONG_CREDENTIALS));
                return;
            }

            if (credential[1] != account.Password)
            {
                client.SendPacket(new IdentificationFailedMessage((uint)IdentificationFailureReasonEnum.WRONG_CREDENTIALS));
                return;
            }

            if (account.IsBanned)
            {
                client.SendPacket(new IdentificationFailedMessage((uint)IdentificationFailureReasonEnum.BANNED));
                return;
            }

            //ici besoin de décoder le compte
            List <Burning.DofusProtocol.Network.Types.GameServerInformations> gameServerInformations = new List <Burning.DofusProtocol.Network.Types.GameServerInformations>();

            gameServerInformations.Add(new Burning.DofusProtocol.Network.Types.GameServerInformations(16, 1, true, (uint)ServerStatusEnum.ONLINE, 0, true, 1, 6, 4655.00));

            client.SendPacket(new CredentialsAcknowledgementMessage());
            client.SendPacket(new IdentificationSuccessMessage(credential[0], credential[1], 1, 1, true, "DELETE ?", 454.00, 4654.00, 54564.00, false, 0));
            client.SendPacket(new ServersListMessage(gameServerInformations, 0, true));

            client.Account        = account;
            client.Account.Ticket = client.salt;
            AccountRepository.Instance.Update(client.Account);
        }
        internal void HandleIdentificationRequest(IMessage receivedMessage)
        {
            _identification = (receivedMessage as IdentificationMessage).Client;

            using (IdentificationMessage message = new IdentificationMessage())
            {
                _identification.PublicName = _clientName;

                ClientProtocol.AddValueToMessage(message, _identification);

                ClientProtocol.SendMessage(message);

                if (ProtocolMadeConnection != null)
                {
                    ProtocolMadeConnection(this, EventArgs.Empty);
                }

            }
        }
Ejemplo n.º 30
0
        public void OnReceivedPacket(object source, PacketEventArg e)
        {
            ServerPacketEnum PacketType = (ServerPacketEnum)e.Packet.MessageID;

            switch (PacketType)
            {
            case ServerPacketEnum.ProtocolRequired: break;

            case ServerPacketEnum.CredentialsAcknowledgementMessage: break;

            case ServerPacketEnum.BasicAckMessage: break;

            case ServerPacketEnum.TextInformationMessage:
                TextInformationMessage text = (TextInformationMessage)e.Packet;
                Log(LogMessageType.Arena, ((TextInformationTypeEnum)text.MsgType).ToString() + "ID = " + text.MsgId);
                for (int i = 0; i < text.Parameters.Count; i++)
                {
                    string t = text.Parameters[i];
                    Log(LogMessageType.Arena, "Parameter[" + i + "] " + t);
                }
                break;

            case ServerPacketEnum.HelloGameMessage:
                Log(LogMessageType.Info, "Connecté au serveur de jeu.");
                HelloGameMessage            helloGame = (HelloGameMessage)e.Packet;
                AuthenticationTicketMessage ATM       = new AuthenticationTicketMessage("fr", _ticket.ToString());
                _GameSocket.Send(ATM);
                break;

            case ServerPacketEnum.RawDataMessage:
                List <int> tt = new List <int>();
                for (int i = 0; i <= 255; i++)
                {
                    Random random = new Random();
                    int    test   = random.Next(-127, 127);
                }
                CheckIntegrityMessage rawData = new CheckIntegrityMessage(tt);
                _GameSocket.Send(rawData);
                break;

            case ServerPacketEnum.HelloConnectMessage:
                Log(LogMessageType.Info, "Connecté au serveur d'authentification.");
                HelloConnectMessage   helloConnectMessage = (HelloConnectMessage)e.Packet;
                sbyte[]               credentials         = RSA.RSAKey.Encrypt(helloConnectMessage.key, accountNameTextField.Text, accountPasswordTextField.Text, helloConnectMessage.salt);
                VersionExtended       version             = new VersionExtended(2, 41, 1, 120264, 1, (sbyte)BuildTypeEnum.RELEASE, 1, 1);
                IdentificationMessage idm = new IdentificationMessage(autoConnectCheckBox.Checked, false, false, version, "fr", credentials, 0, 0, new ushort[0]);
                Log(LogMessageType.Info, "Envois des informations d'identification...");
                _ServerSocket.Send(idm);
                break;

            case ServerPacketEnum.LoginQueueStatusMessage:
                LoginQueueStatusMessage loginQueueStatusMessage = (LoginQueueStatusMessage)e.Packet;
                if (loginQueueStatusMessage.Position != 0 && loginQueueStatusMessage.Total != 0)
                {
                    Log(LogMessageType.Info, "Vous êtes en position " + loginQueueStatusMessage.Position + " sur " + loginQueueStatusMessage.Total + " dans la file d'attente.");
                }
                break;

            case ServerPacketEnum.CurrentMapMessage:
                CurrentMapMessage currentMap = (CurrentMapMessage)e.Packet;
                _GameSocket.Send(new MapInformationsRequestMessage(currentMap.MapId));
                break;

            case ServerPacketEnum.QueueStatusMessage:
                QueueStatusMessage queueStatusMessage = (QueueStatusMessage)e.Packet;
                if (queueStatusMessage.Position != 0 && queueStatusMessage.Total != 0)
                {
                    Log(LogMessageType.Info, "Vous êtes en position " + queueStatusMessage.Position + " sur " + queueStatusMessage.Total + " dans la file d'attente.");
                }
                break;

            case ServerPacketEnum.IdentificationFailedMessage:
                IdentificationFailedMessage msg = (IdentificationFailedMessage)e.Packet;
                Log(LogMessageType.Public, "Identification échouée !");
                Log(LogMessageType.Public, ((IdentificationFailureReasonEnum)msg.Reason).ToString());
                DisconnectHandler();
                break;

            case ServerPacketEnum.IdentificationSuccessMessage: break;

            case ServerPacketEnum.ServerListMessage:
                ServersListMessage servers = (ServersListMessage)e.Packet;
                foreach (GameServerInformations i in servers.Servers)
                {
                    if (i.CharactersCount > 0 && i.IsSelectable && (ServerStatusEnum)i.Status == ServerStatusEnum.ONLINE)
                    {
                        _ServerSocket.Send(new ServerSelectionMessage(i.ObjectID));
                        break;
                    }
                }
                break;

            case ServerPacketEnum.SelectedServerDataMessage:
                SelectedServerDataMessage selected = (SelectedServerDataMessage)e.Packet;
                Log(LogMessageType.Info, "Connexion au serveur " + (ServerNameEnum)selected.ServerId + "...");
                _ticket     = AES.AES.TicketTrans(selected.Ticket);
                _GameSocket = new DofusBotSocket(_deserializer, new IPEndPoint(IPAddress.Parse(selected.Address), selected.Port));
                Log(LogMessageType.Info, "Connexion en cours <" + selected.Address + ":" + selected.Port + ">");
                _GameSocket.ConnectEndListen();
                _ServerSocket.CloseSocket();
                _ServerSocket = null;
                break;

            case ServerPacketEnum.SelectedServerDataExtendedMessage:
                SelectedServerDataExtendedMessage selectedExtended = (SelectedServerDataExtendedMessage)e.Packet;
                Log(LogMessageType.Info, "Connecté au serveur : " + (ServerNameEnum)selectedExtended.ServerId + "...");
                _ticket     = AES.AES.TicketTrans(selectedExtended.Ticket);
                _GameSocket = new DofusBotSocket(_deserializer, new IPEndPoint(IPAddress.Parse(selectedExtended.Address), selectedExtended.Port));
                Log(LogMessageType.Info, "Connexion en cours <" + selectedExtended.Address + ":" + selectedExtended.Port + ">");
                _GameSocket.ConnectEndListen();
                _ServerSocket.CloseSocket();
                _ServerSocket = null;
                break;

            case ServerPacketEnum.AuthenticationTicketAcceptedMessage:
                AuthenticationTicketAcceptedMessage accepted = (AuthenticationTicketAcceptedMessage)e.Packet;
                Thread.Sleep(500);
                _GameSocket.Send(new CharactersListRequestMessage());
                break;

            case ServerPacketEnum.AuthenticationTicketRefusedMessage: break;

            case ServerPacketEnum.GameContextCreateMessage: break;

            case ServerPacketEnum.SetCharacterRestrictionsMessage: break;

            case ServerPacketEnum.BasicNoOperationMessage: break;

            case ServerPacketEnum.NotificationListMessage: break;

            case ServerPacketEnum.CharacterSelectedSuccessMessage: break;

            case ServerPacketEnum.InventoryContentMessage:
                InventoryContentMessage inventory = (InventoryContentMessage)e.Packet;
                Invoke((MethodInvoker) delegate
                {
                    kamasLabel.Text = inventory.Kamas.ToString();
                });
                break;

            case ServerPacketEnum.SetUpdateMessage: break;

            case ServerPacketEnum.ShortcutBarContentMessage: break;

            case ServerPacketEnum.RoomAvailableUpdateMessage: break;

            case ServerPacketEnum.HavenBagPackListMessage: break;

            case ServerPacketEnum.EmoteListMessage: break;

            case ServerPacketEnum.JobDescriptionMessage:
                JobDescriptionMessage jobs = (JobDescriptionMessage)e.Packet;
                foreach (JobDescription j in jobs.JobsDescription)
                {
                    foreach (SkillActionDescription s in j.Skills)
                    {
                        //Log(LogMessageType.Noob, "Métier: " + j.JobId + " | Skill: " + s.SkillId);
                    }
                }
                break;

            case ServerPacketEnum.JobExperienceMultiUpdateMessage: break;

            case ServerPacketEnum.JobCrafterDirectorySettingsMessage: break;

            case ServerPacketEnum.AlignmentRankUpdateMessage: break;

            case ServerPacketEnum.ServerExperienceModificatorMessage: break;

            case ServerPacketEnum.DareCreatedListMessage: break;

            case ServerPacketEnum.AlmanachCalendarDateMessage: break;

            case ServerPacketEnum.CharacterCapabilitiesMessage: break;

            case ServerPacketEnum.GameRolePlayArenaUpdatePlayerInfosAllQueuesMessage: break;

            case ServerPacketEnum.AchievementListMessage: break;

            case ServerPacketEnum.BasicLatencyStatsRequestMessage: break;

            case ServerPacketEnum.GameContextRemoveElementMessage: break;

            case ServerPacketEnum.GameMapChangeOrientationMessage: break;

            case ServerPacketEnum.GameRolePlayShowActorMessage: break;

            case ServerPacketEnum.SpouseStatusMessage: break;

            case ServerPacketEnum.SequenceNumberRequestMessage: break;

            case ServerPacketEnum.GuildMemberWarnOnConnectionStateMessage: break;

            case ServerPacketEnum.WarnOnPermaDeathStateMessage: break;

            case ServerPacketEnum.FriendGuildWarnOnAchievementCompleteStateMessage: break;

            case ServerPacketEnum.FriendWarnOnLevelGainStateMessage: break;

            case ServerPacketEnum.FriendWarnOnConnectionStateMessage: break;

            case ServerPacketEnum.BasicTimeMessage: break;

            case ServerPacketEnum.ServerSettingsMessage: break;

            case ServerPacketEnum.ServerOptionalFeaturesMessage: break;

            case ServerPacketEnum.ServerSessionConstantsMessage: break;

            case ServerPacketEnum.StatedElementUpdatedMessage: break;

            case ServerPacketEnum.InteractiveElementUpdatedMessage: break;

            case ServerPacketEnum.InteractiveUsedMessage: break;

            case ServerPacketEnum.AccountCapabilitiesMessage: break;

            case ServerPacketEnum.TrustStatusMessage: break;

            case ServerPacketEnum.PrismsListMessage: break;

            case ServerPacketEnum.CharacterExperienceGainMessage: break;

            case ServerPacketEnum.IdolListMessage: break;

            case ServerPacketEnum.SpellListMessage: break; break;

            case ServerPacketEnum.EnabledChannelsMessage: break;

            case ServerPacketEnum.GameMapMovementMessage: break;

            case ServerPacketEnum.DareSubscribedListMessage: break;

            case ServerPacketEnum.UpdateMapPlayersAgressableStatusMessage: break;

            case ServerPacketEnum.CharacterStatsListMessage: break;

            case ServerPacketEnum.MapComplementaryInformationsDataMessage:
                MapComplementaryInformationsDataMessage mapInfos = (MapComplementaryInformationsDataMessage)e.Packet;
                Invoke((MethodInvoker) delegate
                {
                    currentMapIdLabel.Text = mapInfos.MapId.ToString();
                });
                break;

            case ServerPacketEnum.LifePointsRegenBeginMessage: break;

            case ServerPacketEnum.GameContextDestroyMessage: break;

            case ServerPacketEnum.IgnoredListMessage: break;

            case ServerPacketEnum.FriendsListMessage:
                FriendsListMessage friendsList = (FriendsListMessage)e.Packet;
                foreach (FriendInformations f in friendsList.FriendsList)
                {
                    Log(LogMessageType.Noob, "Amis: " + f.AccountName + " | Dernière Connexion: " + DateExtensions.UnixTimestampToDateTime(f.LastConnection).ToLongDateString() + " | Points de Succès: " + f.AchievementPoints);
                }
                break;

            case ServerPacketEnum.AccountHouseMessage: break;

            case ServerPacketEnum.StartupActionsListMessage:  break;

            case ServerPacketEnum.ChatCommunityChannelCommunityMessage: break;

            case ServerPacketEnum.DareRewardsListMessage: break;

            case ServerPacketEnum.DareWonListMessage: break;

            case ServerPacketEnum.MailStatusMessage: break;

            case ServerPacketEnum.ChannelEnablingChangeMessage: break;

            case ServerPacketEnum.InventoryWeightMessage:
                InventoryWeightMessage IWM = (InventoryWeightMessage)e.Packet;
                Invoke((MethodInvoker) delegate
                {
                    PodsProgressValue   = IWM.Weight;
                    PodsProgressMaximum = IWM.WeightMax;
                    PodsProgress.Refresh();
                });
                break;

            case ServerPacketEnum.CharacterLoadingCompleteMessage:
                _GameSocket.Send(new FriendsGetListMessage());
                _GameSocket.Send(new IgnoredGetListMessage());
                _GameSocket.Send(new SpouseGetInformationsMessage());
                _GameSocket.Send(new ClientKeyMessage(FlashKeyGenerator.GetRandomFlashKey(accountNameTextField.Text)));
                _GameSocket.Send(new GameContextCreateRequestMessage());
                _GameSocket.Send(new ChannelEnablingMessage(7, false));
                break;

            case ServerPacketEnum.CharactersListMessage:
                CharactersListMessage            charactersList = (CharactersListMessage)e.Packet;
                List <CharacterBaseInformations> characters     = charactersList.Characters;
                for (int i = 0; i < characters.Count; i++)
                {
                    CharacterBaseInformations c = characters[i];
                    Log(LogMessageType.Info, "Connexion sur le personnage " + c.Name);
                    _GameSocket.Send(new CharacterSelectionMessage((ulong)c.ObjectID));
                    break;
                }
                break;

            default:
                Log(LogMessageType.Admin, "Packet: [" + (ServerPacketEnum)e.Packet.MessageID + "] is not handled.");
                break;
            }
        }
Ejemplo n.º 31
0
 public void HandleIdentificationMessage(Behaviors.Bot bot, IdentificationMessage message)
 {
     Dispatcher.Invoke(new Action(() => CloseChildByLogin(message.login)));
 }
Ejemplo n.º 32
0
 public static IEnumerable <NetworkMessage> HandleIdentificationMessage(AuthClient client, IdentificationMessage message)
 {
     client.Disconnect();
     // Add to queue etc...
     return(Enumerable.Empty <NetworkMessage>());
 }