public InstanceClientSession(ILog logger, INetworkMessagePayloadSenderService sender, IConnectionDetails details, INetworkMessageSubscriptionService subService, IDisconnectionServiceHandler disconnectHandler, IRequestMessageHandlerService <InstanceClientSession> requestMessageHandlers) : base(logger, sender, details, subService, disconnectHandler) { if (requestMessageHandlers == null) { throw new ArgumentNullException(nameof(requestMessageHandlers), $"Cannot provide a null {nameof(IRequestMessageHandlerService<InstanceClientSession>)}."); } requestMessageHandlerService = requestMessageHandlers; }
/// <inheritdoc /> public override ClientPeerSession CreateIncomingPeerSession(INetworkMessagePayloadSenderService sender, IConnectionDetails details, INetworkMessageSubscriptionService subService, IDisconnectionServiceHandler disconnectHandler) { //For now we assume that any connection is valid. //In the future we might filter out some IPs but most validation will be post-connection from a signed message. ClientPeerSession session = new InstanceClientSession(Logger, sender, details, subService, disconnectHandler, instanceSessionRequestMessageHandlerService); //Register the OnDisconnect UnityEvent for when the session disconnects disconnectHandler.DisconnectionEventHandler += () => OnSessionDisconnected?.Invoke(session); //This isn't great; invoking this before returning it to the server base is not great design but it's the only way right now OnNewSessionCreated?.Invoke(session); return(session); }