protected virtual void OnSocketConnection(Socket socket) { var connection = new AuthConnectionHandler <TAuthIdentity, TSendModel, TReceiveModel>(socket, this.userProvider, this.config); connection.OnAuthResolvedEvent += this.OnAuthConnection; connection.OnPacketReceivedEvent += this.OnContentReceived; connection.StartReceive(); this.OnConnectionEvent?.Invoke(this, connection); }
protected virtual void OnAuthConnection(AuthConnectionHandler <TAuthIdentity, TSendModel, TReceiveModel> connection, TAuthIdentity identity) { if (this.activeConnections.ContainsValue(identity)) { var currentConnection = this.activeConnections.First(x => x.Value == identity).Key; currentConnection.Disconnect($"A second connection was opened for user {identity.AuthToken}"); this.activeConnections.Remove(currentConnection); } this.activeConnections.Add(connection, identity); this.OnAuthConnectionEvent?.Invoke(connection, identity); }