Beispiel #1
0
        private void OnWorldClientConnected(ConnectionMITM client)
        {
            // todo : config
            client.Send(new ProtocolRequired(1467, 1467));
            client.Send(new HelloGameMessage());

            logger.Debug("World client connected");
        }
Beispiel #2
0
 private void OnWorldClientDisconnected(ConnectionMITM client)
 {
     client.Bot.Dispose();
 }
Beispiel #3
0
 private void OnAuthClientDisconnected(ConnectionMITM client)
 {
     if (client.Bot.ExpectedDisconnection)
         client.Bot.AddMessage(client.Bot.Stop);
     else client.Bot.Dispose();
 }
Beispiel #4
0
        private void OnServerConnectionTimedOut(ConnectionMITM connection)
        {
            if (!connection.Server.IsConnected)
                logger.Error("Cannot etablish a connection to the server ({0}). Time out {1}ms", connection.Server.IP, ServerConnectionTimeout * 1000);
            else
            {
                logger.Warn("Send a BasicPingMessage to unblock the server connection");

                // unblock the connection (fix #14)
                connection.SendToServer(new BasicPingMessage());
            }
        }
Beispiel #5
0
        private void HandleAuthenticationTicketMessage(ConnectionMITM client, AuthenticationTicketMessage message)
        {
            if (!m_tickets.ContainsKey(message.ticket))
                throw new Exception(string.Format("Ticket {0} not registered", message.ticket));

            var tuple = m_tickets[message.ticket];

            m_tickets.Remove(message.ticket);

            client.Bot = tuple.Item1;
            client.Bot.ChangeConnection(client);
            client.Bot.ConnectionType = ClientConnectionType.GameConnection;
            client.Bot.CancelAllMessages(); // avoid to handle message from the auth client.
            client.Bot.Start();

            ( (NetworkMessageDispatcher) client.Bot.Dispatcher ).Client = client;
            ( (NetworkMessageDispatcher) client.Bot.Dispatcher ).Server = client.Server;

            try
            {
                client.BindToServer(tuple.Item2.address, tuple.Item2.port);
            }
            catch (Exception)
            {
                logger.Error("Cannot connect to {0}:{1}.", tuple.Item2.address, tuple.Item2.port);
                client.Bot.Stop();
                return;
            }

            // unblock the connection (fix #14)
            client.SendToServer(new BasicPingMessage());

            client.Bot.CallDelayed(ServerConnectionTimeout * 1000, () => OnServerConnectionTimedOut(client));
            logger.Debug("Bot retrieved with ticket {0}", message.ticket);
        }
Beispiel #6
0
        private void OnAuthClientConnected(ConnectionMITM client)
        {
            client.Bot.Start();

            try
            {
                client.BindToServer(m_configuration.RealAuthHost, m_configuration.RealAuthPort);
            }
            catch (Exception)
            {
                logger.Error("Cannot connect to {0}:{1}.", m_configuration.RealAuthHost, m_configuration.RealAuthPort);
                client.Bot.Stop();
                return;
            }

            logger.Debug("Auth client connected");
        }
Beispiel #7
0
        private ConnectionMITM CreateAuthClient(Socket socket)
        {
            if (socket == null) throw new ArgumentNullException("socket");
            var client = new ConnectionMITM(socket, MessageBuilder);
            client.MessageReceived += OnAuthClientMessageReceived;

            var dispatcher = new NetworkMessageDispatcher {Client = client, Server = client.Server};

            var bot = new BotMITM(client, dispatcher);
            client.Bot = bot;
            bot.ConnectionType = ClientConnectionType.Authentification;

            BotManager.Instance.RegisterBot(bot);

            return client;
        }
Beispiel #8
0
 private void OnAuthClientDisconnected(ConnectionMITM client)
 {
     client.Bot.Stop();
 }
Beispiel #9
0
 public void ChangeConnection(ConnectionMITM connection)
 {
     Connection = connection;
 }
Beispiel #10
0
 public BotMITM(ConnectionMITM connection, NetworkMessageDispatcher dispatcher)
     : base(dispatcher)
 {
     Connection = connection;
 }
Beispiel #11
0
 private void OnWorldClientDisconnected(ConnectionMITM client)
 {
     if (client.Bot != null)
     client.Bot.AddMessage(client.Bot.Dispose);
 }
Beispiel #12
0
        private void OnAuthClientConnected(ConnectionMITM client)
        {
            client.Bot.Start();

            try
            {
                client.BindToServer(m_configuration.RealAuthHost, m_configuration.RealAuthPort); 
            }
            catch (Exception)
            {
                logger.Error("Cannot connect to {0}:{1}.", m_configuration.RealAuthHost, m_configuration.RealAuthPort);
                client.Bot.Stop();
                return;
            }

            // unblock the connection (fix #14)
            client.SendToServer(new BasicPingMessage());

            logger.Debug("Auth client connected");
        }
Beispiel #13
0
 private void OnAuthClientDisconnected(ConnectionMITM client)
 {
     // stop the bot after it ends process stuff
     client.Bot.AddMessage(client.Bot.Stop);
 }
Beispiel #14
0
 public void ChangeConnection(ConnectionMITM connection)
 {
     Connection = connection;
 }
Beispiel #15
0
        private ConnectionMITM CreateWorldClient(Socket socket)
        {
            if (socket == null) throw new ArgumentNullException("socket");
            var client = new ConnectionMITM(socket, MessageBuilder);
            client.MessageReceived += OnWorldClientMessageReceived;

            return client;
        }
Beispiel #16
0
 public BotMITM(ConnectionMITM connection, NetworkMessageDispatcher dispatcher)
     : base(dispatcher)
 {
     Connection = connection;
 }
Beispiel #17
0
        private void HandleAuthenticationTicketMessage(ConnectionMITM client, AuthenticationTicketMessage message)
        {
            if (!m_tickets.ContainsKey(message.ticket))
                throw new Exception(string.Format("Ticket {0} not registered", message.ticket));

            var tuple = m_tickets[message.ticket];

            m_tickets.Remove(message.ticket);

            client.Bot = tuple.Item1;
            client.Bot.ChangeConnection(client);
            client.Bot.ConnectionType = ClientConnectionType.GameConnection;
            client.Bot.Start();

            ( client.Bot.Dispatcher as NetworkMessageDispatcher ).Client = client;
            ( client.Bot.Dispatcher as NetworkMessageDispatcher ).Server = client.Server;

            try
            {
                client.BindToServer(tuple.Item2.address, tuple.Item2.port);
            }
            catch (Exception)
            {
                logger.Error("Cannot connect to {0}:{1}.", tuple.Item2.address, tuple.Item2.port);
                client.Bot.Stop();
                return;
            }

            logger.Debug("Bot retrieved with ticket {0}", message.ticket);
        }