コード例 #1
0
ファイル: IonTcpConnectionListener.cs プロジェクト: habb0/IHI
        /// <summary>
        ///   Invoked when the listener asynchronously accepts a new Connection request.
        /// </summary>
        /// <param name = "iAr">The IAsyncResult object holding the results of the asynchronous BeginAcceptSocket operation.</param>
        private void ConnectionRequest(IAsyncResult iAr)
        {
            try
            {
                Socket socket = _listener.EndAcceptSocket(iAr);
                // TODO: IP blacklist

                IonTcpConnection connection = _factory.CreateConnection(socket);
                if (connection != null)
                {
                    _manager.HandleNewConnection(connection);
                }
            }
// ReSharper disable EmptyGeneralCatchClause
            catch
            {
            } // TODO: handle exceptions
// ReSharper restore EmptyGeneralCatchClause
            finally
            {
                if (IsListening)
                {
                    WaitForNextConnection(); // Re-start the process for next Connection
                }
            }
        }
コード例 #2
0
ファイル: IonTcpConnectionManager.cs プロジェクト: habb0/IHI
 public IEnumerable <IonTcpConnection> GetAllConnections()
 {
     IonTcpConnection[] returnArray;
     lock (_connections)
     {
         returnArray = new IonTcpConnection[_connections.Count];
         _connections.Values.CopyTo(returnArray, 0);
     }
     return(returnArray);
 }
コード例 #3
0
ファイル: IonTcpConnectionManager.cs プロジェクト: habb0/IHI
        public bool TestConnection(uint clientID)
        {
            IonTcpConnection connection = GetConnection(clientID);

            if (connection != null)
            {
                return(connection.TestConnection()); // Try to send data
            }
            return(false);                           // Connection not here!
        }
コード例 #4
0
        /// <summary>
        /// Creates an IonTcpConnection instance for a given socket and assigns it an unique ID.
        /// </summary>  
        /// <param name="Socket">The System.Networking.Socket.Sockets object to base the Connection on.</param>
        /// <returns>IonTcpConnection</returns>
        public IonTcpConnection CreateConnection(Socket Socket)
        {
            if (Socket == null)
                return null;

            IonTcpConnection Connection = new IonTcpConnection(++mConnectionCounter, Socket);
            CoreManager.GetCore().GetStandardOut().PrintNotice(string.Format("Created Connection for {0}.", Connection.GetIPAddressString()));

            return Connection;
        }
コード例 #5
0
ファイル: IonTcpConnectionManager.cs プロジェクト: habb0/IHI
        internal void CloseConnection(uint connectionID)
        {
            IonTcpConnection connection = GetConnection(connectionID);

            if (connection == null)
            {
                return;
            }
            connection.Stop();
            _connections.Remove(connectionID);
        }
コード例 #6
0
ファイル: IonTcpConnectionFactory.cs プロジェクト: habb0/IHI
        /// <summary>
        ///   Creates an IonTcpConnection instance for a given socket and assigns it an unique ID.
        /// </summary>
        /// <param name = "socket">The System.Networking.Socket.Sockets object to base the Connection on.</param>
        /// <returns>IonTcpConnection</returns>
        public IonTcpConnection CreateConnection(Socket socket)
        {
            if (socket == null)
                return null;

            IonTcpConnection connection = new IonTcpConnection(++Count, socket);
            CoreManager.ServerCore.GetStandardOut().PrintNotice(string.Format("Created Connection for {0}.",
                                                                              connection.GetIPAddressString()));

            return connection;
        }
コード例 #7
0
ファイル: IonTcpConnectionFactory.cs プロジェクト: habb0/IHI
        /// <summary>
        ///   Creates an IonTcpConnection instance for a given socket and assigns it an unique ID.
        /// </summary>
        /// <param name = "socket">The System.Networking.Socket.Sockets object to base the Connection on.</param>
        /// <returns>IonTcpConnection</returns>
        public IonTcpConnection CreateConnection(Socket socket)
        {
            if (socket == null)
            {
                return(null);
            }

            IonTcpConnection connection = new IonTcpConnection(++Count, socket);

            CoreManager.ServerCore.GetStandardOut().PrintNotice(string.Format("Created Connection for {0}.",
                                                                              connection.GetIPAddressString()));

            return(connection);
        }
コード例 #8
0
ファイル: IonTcpConnectionManager.cs プロジェクト: habb0/IHI
        public void DropConnection(uint clientID)
        {
            IonTcpConnection connection = GetConnection(clientID);

            if (connection == null)
            {
                return;
            }
            CoreManager.ServerCore.GetStandardOut().PrintNotice("Dropped Connection => " +
                                                                connection.GetIPAddressString());

            connection.Stop();
            lock (_connections)
                _connections.Remove(clientID);
        }
コード例 #9
0
ファイル: IonTcpConnectionManager.cs プロジェクト: habb0/IHI
        /// <summary>
        ///   Handles a newly created IonTcpConnection and performs some checks, before adding it to the Connection collection and starting the client session.
        /// </summary>
        /// <param name = "connection">The IonTcpConnection instance representing the new Connection to handle.</param>
        public void HandleNewConnection(IonTcpConnection connection)
        {
            // TODO: check max simultaneous connections
            // TODO: check max simultaneous connections per IP
            // TODO: check project specific actions

            // INFO: client ID = Connection ID, client ID = session ID
            // Add Connection to collection
            lock (_connections)
                _connections.Add(connection.GetID(), connection);

            if (OnConnectionOpen != null)
            {
                OnConnectionOpen.Invoke(connection, null);
            }

            connection.Start();

            //IonEnvironment.GetHabboHotel().GetClients().StartClient(Connection.ID);
        }
コード例 #10
0
ファイル: HabboDistributor.cs プロジェクト: habb0/IHI
 /// <summary>
 ///   Creates a minimal Habbo object.
 ///   This is not cached and is only used after the Habbo connects but before logging in.
 ///   Do not use this Habbo for custom features. Use a cached version.
 /// </summary>
 /// <param name = "connection">The Connection this Habbo is for.</param>
 /// <returns>A mostly non-function Habbo.</returns>
 public Habbo GetPreLoginHabbo(IonTcpConnection connection)
 {
     return new Habbo(connection);
 }
コード例 #11
0
ファイル: Habbo.cs プロジェクト: habb0/IHI
        public void LoginMerge(Habbo loggedInUser)
        {
            _connection = loggedInUser._connection;

            _connection.Habbo = this;
        }
コード例 #12
0
ファイル: Habbo.cs プロジェクト: habb0/IHI
 /// <summary>
 ///   Construct a prelogin User object.
 ///   DO NOT USE THIS FOR GETTING A USER - USE THE USER DISTRIBUTOR
 /// </summary>
 internal Habbo(IonTcpConnection connection)
 {
     _connection = connection;
 }
コード例 #13
0
        /// <summary>
        /// Handles a newly created IonTcpConnection and performs some checks, before adding it to the Connection collection and starting the client session.
        /// </summary>
        /// <param name="Connection">The IonTcpConnection instance representing the new Connection to handle.</param>
        public void HandleNewConnection(IonTcpConnection Connection)
        {
            // TODO: check max simultaneous connections
            // TODO: check max simultaneous connections per IP
            // TODO: check project specific actions

            // INFO: client ID = Connection ID, client ID = session ID
            // Add Connection to collection
            lock (mConnections)
                mConnections.Add(Connection.GetID(), Connection);

            Connection.Start();

            if (this.OnConnectionOpen != null)
            {
                this.OnConnectionOpen.Invoke(Connection, null);
            }

            //IonEnvironment.GetHabboHotel().GetClients().StartClient(Connection.ID);
        }
コード例 #14
0
 public IonTcpConnection[] GetAllConnections()
 {
     IonTcpConnection[] ReturnArray;
     lock(this.mConnections)
     {
         ReturnArray = new IonTcpConnection[this.mConnections.Count];
         this.mConnections.Values.CopyTo(ReturnArray, 0);
     }
     return ReturnArray;
 }