示例#1
0
        public bool TestConnection(uint clientID)
        {
            IonTcpConnection connection = GetConnection(clientID);

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

            IonTcpConnection connection = new IonTcpConnection(++mConnectionCounter, pSocket);
            Core.GetStandardOut().PrintNotice(string.Format("Created Connection for {1}.", connection.ipAddress));

            return connection;
        }
示例#3
0
        public void DropConnection(uint clientID)
        {
            IonTcpConnection connection = GetConnection(clientID);

            if (connection != null)
            {
                Core.GetStandardOut().PrintNotice("Dropped Connection => " + connection.ipAddress);

                connection.Stop();
                mConnections.Remove(clientID);
            }
        }
        public void DropConnection(uint clientID)
        {
            IonTcpConnection connection = GetConnection(clientID);

            if (connection != null)
            {
                IonEnvironment.GetLog().WriteInformation("Dropped IonTcpConnection [" + clientID + "] of " + connection.ipAddress);

                connection.Stop();
                mConnections.Remove(clientID);
            }
        }
示例#5
0
        /// <summary>
        /// Creates an IonTcpConnection instance for a given socket and assigns it an unique ID.
        /// </summary>
        /// <param name="pSocket">The System.Net.Socket.Sockets object to base the connection on.</param>
        /// <returns>IonTcpConnection</returns>
        public IonTcpConnection CreateConnection(Socket pSocket)
        {
            if (pSocket == null)
            {
                return(null);
            }

            IonTcpConnection connection = new IonTcpConnection(++mConnectionCounter, pSocket);

            Core.GetStandardOut().PrintNotice(string.Format("Created Connection for {1}.", connection.ipAddress));

            return(connection);
        }
示例#6
0
        /// <summary>
        /// Creates an IonTcpConnection instance for a given socket and assigns it an unique ID.
        /// </summary>
        /// <param name="pSocket">The System.Net.Socket.Sockets object to base the connection on.</param>
        /// <returns>IonTcpConnection</returns>
        public IonTcpConnection CreateConnection(Socket pSocket)
        {
            if (pSocket == null)
            {
                return(null);
            }

            IonTcpConnection connection = new IonTcpConnection(++mConnectionCounter, pSocket);

            IonEnvironment.GetLog().WriteInformation(string.Format("Created IonTcpConnection [{0}] for {1}.", connection.ID, connection.ipAddress));

            return(connection);
        }
        /// <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
            mConnections.Add(connection.ID, connection);

            // Create session for new client
            IonEnvironment.GetHabboHotel().GetClients().StartClient(connection.ID);
        }
        /// <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 pSocket = mListener.EndAcceptSocket(iAr);
                // TODO: IP blacklist

                IonTcpConnection connection = mFactory.CreateConnection(pSocket);
                if (connection != null)
                {
                    mManager.HandleNewConnection(connection);
                }
            }
            catch { } // TODO: handle exceptions
            finally
            {
                if (mIsListening)
                {
                    WaitForNextConnection(); // Re-start the process for next connection
                }
            }
        }
        /// <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
            mConnections.Add(connection.ID, connection);

            // Create session for new client
            IonEnvironment.GetHabboHotel().GetClients().StartClient(connection.ID);
        }
示例#10
0
文件: User.cs 项目: habb0/IHI
 /// <summary>
 /// Cleans up the online values when nobody is using them.
 /// </summary>
 public void StopLoggedInValues()
 {
     OnlineValueCounter--;
     if (OnlineValueCounter == 0)
     {
         this.fConnection = null;
         this.fPacketSender = null;
         this.fPacketProcessor = null;
         this.fSessionValues = null;
         this.fFuseRights = null;
     }
 }
示例#11
0
文件: User.cs 项目: habb0/IHI
        /// <summary>
        /// Ensure that the online values are present.
        /// ALWAYS CALL StopLoggedInValues() WHEN YOU ARE FINISHED!
        /// </summary>
        public void StartLoggedInValues(IonTcpConnection Connection)
        {
            OnlineValueCounter++;
            if (OnlineValueCounter == 1)
            {
                this.fPonged = true;

                this.fFuseRights = Core.GetFuseManager().GetUserRights(this.fID);
                this.fSessionValues = new Dictionary<object, object>();
            }
        }
示例#12
0
文件: User.cs 项目: habb0/IHI
 /// <summary>
 /// Construct a prelogin User object.
 /// DO NOT USE THIS FOR GETTING A USER - USE THE USER DISTRIBUTOR
 /// </summary>
 internal User(IonTcpConnection Connection)
 {
     this.fConnection = Connection;
     this.fPacketSender = new PacketSender(this);
     this.fPacketProcessor = new PacketProcessor(this);
 }
示例#13
0
 /// <summary>
 /// Constructs a GameClient instance for a given client ID.
 /// </summary>
 /// <param name="clientID">The ID of this client.</param>
 public GameClient(uint clientID)
 {
     mID = clientID;
     mConnection = IonEnvironment.GetTcpConnections().GetConnection(clientID);
     mMessageHandler = new ClientMessageHandler(this);
 }
示例#14
0
        /// <summary>
        /// Stops the client, removes this user from room, updates last online values etc.
        /// </summary>
        public void Stop()
        {
            // Leave room
            // Update last online
            mHabbo = null;
            mConnection = null;

            mMessageHandler.Destroy();
            mMessageHandler = null;
        }