/// <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(); }
/// <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"); } }
/// <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"); } }
/// <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."); } }
/// <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."); } }
/// <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); }
/// <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; }
/// <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; }
/// <summary> /// Disposes this instance. /// </summary> internal void Dispose() { _packet.Clear(); _userConnection = null; }
/// <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(); }