Beispiel #1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="GameClient" /> class.
 /// </summary>
 /// <param name="clientId">The client identifier.</param>
 /// <param name="connection">The connection.</param>
 internal GameClient(uint clientId, ConnectionData connection)
 {
     ConnectionId = clientId;
     _connection = connection;
     CurrentRoomUserId = -1;
     PacketParser = new ServerPacketParser();
 }
Beispiel #2
0
 /// <summary>
 /// Closes the connection.
 /// </summary>
 /// <param name="connection">The connection.</param>
 /// <param name="exception"></param>
 private static void OnClientDisconnected(ConnectionData connection, Exception exception)
 {
     try
     {
         Yupi.GetGame().GetClientManager().DisposeConnection(connection.GetConnectionId());
     }
     catch (Exception ex)
     {
         ServerLogManager.HandleException(ex, "Yupi.Configuration.ConnectionHandling");
     }
 }
Beispiel #3
0
 /// <summary>
 /// Managers the connection event.
 /// </summary>
 /// <param name="connection">The connection.</param>
 private static void OnClientConnected(ConnectionData connection)
 {
     try
     {
         Yupi.GetGame().GetClientManager().CreateAndStartClient(connection.GetConnectionId(), connection);
     }
     catch (Exception ex)
     {
         ServerLogManager.HandleException(ex, "Yupi.Configuration.ConnectionHandling");
     }
 }
Beispiel #4
0
 /// <summary>
 ///     Closes the connection.
 /// </summary>
 /// <param name="connection">The connection.</param>
 /// <param name="exception"></param>
 private static void OnClientDisconnected(ConnectionData connection, Exception exception)
 {
     try
     {
         Yupi.GetGame().GetClientManager().DisposeConnection(connection.GetConnectionId());
     }
     catch (Exception ex)
     {
         YupiLogManager.LogException(ex, "Failed Releasing Old Connection.");
     }
 }
Beispiel #5
0
 /// <summary>
 ///     Managers the connection event.
 /// </summary>
 /// <param name="connection">The connection.</param>
 private static void OnClientConnected(ConnectionData connection)
 {
     try
     {
         Yupi.GetGame().GetClientManager().CreateAndStartClient(connection.GetConnectionId(), connection);
     }
     catch (Exception ex)
     {
         YupiLogManager.LogException(ex, "Failed Handling New Connection.");
     }
 }
Beispiel #6
0
        /// <summary>
        ///     Creates the and start client.
        /// </summary>
        /// <param name="clientId">The client identifier.</param>
        /// <param name="connection">The connection.</param>
        internal void CreateAndStartClient(uint clientId, ConnectionData connection)
        {
            GameClient gameClient = new GameClient(clientId, connection);

            Clients.AddOrUpdate(clientId, gameClient, (key, value) => gameClient);
            _clientsAddQueue.Enqueue(gameClient);
        }
Beispiel #7
0
        /// <summary>
        ///     Stops this instance.
        /// </summary>
        internal void Stop()
        {
            if (GetMessageHandler() != null)
                GetMessageHandler().Destroy();

            if (GetHabbo() != null)
                GetHabbo().OnDisconnect("disconnect");

            CurrentRoomUserId = -1;
            _messageHandler = null;
            _habbo = null;
            _connection = null;
        }
Beispiel #8
0
 /// <summary>
 /// Sets the connection.
 /// </summary>
 /// <param name="con">The con.</param>
 /// <param name="me">Me.</param>
 public void SetConnection(ConnectionData con, GameClient me)
 {
     _currentClient = me;
 }
Beispiel #9
0
 /// <summary>
 ///     Disposes this instance.
 /// </summary>
 internal void Dispose()
 {
     _packet.Clear();
     _userConnection = null;
 }
Beispiel #10
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="QueuedServerMessage" /> class.
 /// </summary>
 /// <param name="connection">The connection.</param>
 public QueuedServerMessage(ConnectionData connection)
 {
     _userConnection = connection;
     _packet = new List<byte>();
 }
        private void OnAcceptSocket(IAsyncResult ar)
        {
            try
            {
                Socket socket = _listener.EndAcceptSocket(ar);
                if (socket.Connected)
                {
                    if (SocketConnectionCheck.CheckConnection(socket, MaxIpConnectionCount, AntiDDosStatus))
                    {
                        socket.NoDelay = _disableNagleAlgorithm;
                        AcceptedConnections++;

                        ConnectionData connectionInfo = new ConnectionData(socket, _parser.Clone() as IDataParser,
                            AcceptedConnections) {Disconnected = OnChannelDisconnect};
                        OnClientConnected(connectionInfo);
                    }
                }
            }
            catch
            {
                // ignored
            }

            try
            {
                _listener?.BeginAcceptSocket(OnAcceptSocket, _listener);
            }
            catch
            {
                // ignored
            }
        }
 private void OnChannelDisconnect(ConnectionData connection, Exception exception)
 {
     connection.Disconnected = null;
     OnClientDisconnected(connection, exception);
     connection.Cleanup();
 }