예제 #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();
 }
예제 #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");
     }
 }
예제 #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");
     }
 }
예제 #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.");
     }
 }
예제 #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.");
     }
 }
예제 #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);
        }
예제 #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;
        }
예제 #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;
 }
예제 #9
0
 /// <summary>
 ///     Disposes this instance.
 /// </summary>
 internal void Dispose()
 {
     _packet.Clear();
     _userConnection = null;
 }
예제 #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>();
 }
예제 #11
0
        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
            }
        }
예제 #12
0
 private void OnChannelDisconnect(ConnectionData connection, Exception exception)
 {
     connection.Disconnected = null;
     OnClientDisconnected(connection, exception);
     connection.Cleanup();
 }