/// <inheritdoc /> protected ManagedClientSession(IManagedNetworkServerClient <TPayloadWriteType, TPayloadReadType> internalManagedNetworkClient, SessionDetails details) { if (internalManagedNetworkClient == null) { throw new ArgumentNullException(nameof(internalManagedNetworkClient)); } if (details == null) { throw new ArgumentNullException(nameof(details)); } InternalManagedNetworkClient = internalManagedNetworkClient; Details = details; }
public SessionStatusChangeEventArgs(ConnectionStatus status, SessionDetails details) { if (details == null) { throw new ArgumentNullException(nameof(details)); } if (!Enum.IsDefined(typeof(ConnectionStatus), status)) { throw new ArgumentOutOfRangeException(nameof(status), "Value should be defined in the ConnectionStatus enum."); } Status = status; Details = details; }
protected override ManagedClientSession <TPayloadWriteType, TPayloadReadType> CreateIncomingSession(IManagedNetworkServerClient <TPayloadWriteType, TPayloadReadType> client, SessionDetails details) { Logger.Info($"Recieved proxy connection from: {details.Address.AddressEndpoint.ToString()}:{details.Address.Port}"); TcpClient proxyClientTcpClient = new TcpClient(ProxyToEndpointAddress.AddressEndpoint.ToString(), ProxyToEndpointAddress.Port); //We need to create the proxy client now too var proxyClient = CreateOutgoingSessionPipeline(proxyClientTcpClient); //We need to use AutoFac lifetime scope so we can register the individual specific dependencies for the //session GenericProxiedManagedClientSession <TPayloadWriteType, TPayloadReadType> connectionSession = BuildSessionFromDependencies <TPayloadWriteType, TPayloadReadType>(client, details, proxyClient); //After the connection session is made with the message context factory that has a dependency on the proxyclient we must create the proxy client's session //which makes it easier to manage and it will have a dependency on the actual session GenericProxiedManagedClientSession <TPayloadReadType, TPayloadWriteType> clientProxySession = BuildSessionFromDependencies <TPayloadReadType, TPayloadWriteType>(proxyClient, details, client); //Now they can both communicate between eachother through the handler's message contexts //However since the AppBase only takes one session type, to maintain this session we need to manually start it //with the ManualClientConnectionLoop below. A copy-paste from the AppBase. Task.Factory.StartNew(async() => { await ManualStartClientConnectionLoop(proxyClientTcpClient, proxyClient, clientProxySession).ConfigureAwait(false); }) .ConfigureAwait(false); return(connectionSession); }
private GenericProxiedManagedClientSession <TWriteType, TReadType> BuildSessionFromDependencies <TWriteType, TReadType>(IManagedNetworkClient <TWriteType, TReadType> client, SessionDetails details, IManagedNetworkClient <TReadType, TWriteType> proxyClient) where TReadType : class where TWriteType : class { GenericProxiedManagedClientSession <TWriteType, TReadType> connectionSession; using (ILifetimeScope lifetimeScope = this.ServiceContainer.BeginLifetimeScope(c => { c.RegisterInstance(client) .AsImplementedInterfaces() .AsSelf(); c.RegisterInstance(details) .As <SessionDetails>(); c.RegisterInstance(new GenericMessageContextFactory <TWriteType, TReadType>(proxyClient)) .AsSelf() .AsImplementedInterfaces(); })) { connectionSession = GenerateClientFromLifetimeScope <TWriteType, TReadType>(lifetimeScope); } return(connectionSession); }
public IProxiedMessageContext <TPayloadWriteType, TPayloadReadType> CreateMessageContext(IConnectionService connectionService, IPeerPayloadSendService <TPayloadWriteType> sendService, SessionDetails details) { return(new GenericProxiedMessageContext <TPayloadWriteType, TPayloadReadType>(ProxyConnection, connectionService, sendService, MockedPeerRequestService)); }
/// <inheritdoc /> public DisconnectedSessionStatusChangeEventArgs(SessionDetails details) : base(ConnectionStatus.Disconnected, details) { }
/// <inheritdoc /> public GenericProxiedManagedClientSession(IManagedNetworkServerClient <TPayloadWriteType, TPayloadReadType> internalManagedNetworkClient, SessionDetails details, [NotNull] MessageHandlerService <TPayloadReadType, TPayloadWriteType, IProxiedMessageContext <TPayloadWriteType, TPayloadReadType> > authMessageHandlerService, IGenericMessageContextFactory <TPayloadWriteType, IProxiedMessageContext <TPayloadWriteType, TPayloadReadType> > messageContextFactory) : base(internalManagedNetworkClient, details, authMessageHandlerService, messageContextFactory) { }
/// <inheritdoc /> public ProxiedManagedClientSession(IManagedNetworkServerClient <TPayloadWriteType, TPayloadReadType> internalManagedNetworkClient, SessionDetails details, [NotNull] MessageHandlerService <TPayloadReadType, TPayloadWriteType, TMessageContextType> authMessageHandlerService, IGenericMessageContextFactory <TPayloadWriteType, TMessageContextType> messageContextFactory) : base(internalManagedNetworkClient, details) { if (authMessageHandlerService == null) { throw new ArgumentNullException(nameof(authMessageHandlerService)); } AuthMessageHandlerService = authMessageHandlerService; MessageContextFactory = messageContextFactory; }