/// <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 } } }
public IEnumerable <IonTcpConnection> GetAllConnections() { IonTcpConnection[] returnArray; lock (_connections) { returnArray = new IonTcpConnection[_connections.Count]; _connections.Values.CopyTo(returnArray, 0); } return(returnArray); }
public bool TestConnection(uint clientID) { IonTcpConnection connection = GetConnection(clientID); if (connection != null) { return(connection.TestConnection()); // Try to send data } return(false); // Connection not here! }
/// <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; }
internal void CloseConnection(uint connectionID) { IonTcpConnection connection = GetConnection(connectionID); if (connection == null) { return; } connection.Stop(); _connections.Remove(connectionID); }
/// <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; }
/// <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); }
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); }
/// <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); }
/// <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); }
public void LoginMerge(Habbo loggedInUser) { _connection = loggedInUser._connection; _connection.Habbo = this; }
/// <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; }
/// <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); }
public IonTcpConnection[] GetAllConnections() { IonTcpConnection[] ReturnArray; lock(this.mConnections) { ReturnArray = new IonTcpConnection[this.mConnections.Count]; this.mConnections.Values.CopyTo(ReturnArray, 0); } return ReturnArray; }