/// <inheritdoc /> public ZoneClientSession(IManagedNetworkServerClient <GameServerPacketPayload, GameClientPacketPayload> internalManagedNetworkClient, SessionDetails details, MessageHandlerService <GameClientPacketPayload, GameServerPacketPayload, IPeerSessionMessageContext <GameServerPacketPayload> > messageHandlers, [NotNull] ILog logger) : base(internalManagedNetworkClient, details) { MessageHandlers = messageHandlers ?? throw new ArgumentNullException(nameof(messageHandlers)); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
/// <inheritdoc /> public AuthServerClientSession(IManagedNetworkServerClient <AuthenticationServerPayload, AuthenticationClientPayload> internalManagedNetworkClient, SessionDetails details, [NotNull] MessageHandlerService <AuthenticationClientPayload, AuthenticationServerPayload, IPeerSessionMessageContext <AuthenticationServerPayload> > authMessageHandlerService) : base(internalManagedNetworkClient, details) { if (authMessageHandlerService == null) { throw new ArgumentNullException(nameof(authMessageHandlerService)); } AuthMessageHandlerService = authMessageHandlerService; }
/// <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; }
/// <inheritdoc /> protected override GenericProxiedManagedClientSession <TWriteType, TReadType> GenerateClientFromLifetimeScope <TWriteType, TReadType>(ILifetimeScope lifetimeScope) { //TODO: This is a hack, we need a better way. The only way we know this is the case is because of details elsewhere IManagedNetworkServerClient <TWriteType, TReadType> client = lifetimeScope.Resolve <IManagedNetworkServerClient <TWriteType, TReadType> >(); bool isServer = (client is ManagedNetworkServerClient <WoWClientWriteServerReadProxyPacketPayloadReaderWriterDecorator <NetworkClientBase, GamePacketPayload, GamePacketPayload, IGamePacketPayload>, GamePacketPayload, GamePacketPayload>); //If it's the server one return(new GenericProxiedManagedClientSession <TWriteType, TReadType>( client, lifetimeScope.Resolve <SessionDetails>(), lifetimeScope.ResolveNamed <MessageHandlerService <TReadType, TWriteType, IProxiedMessageContext <TWriteType, TReadType> > >(isServer ? "Server" : "Client"), lifetimeScope.Resolve <IGenericMessageContextFactory <TWriteType, IProxiedMessageContext <TWriteType, TReadType> > >())); }
/// <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; }
protected override ManagedClientSession <BaseGameServerPayload, BaseGameClientPayload> CreateIncomingSession(IManagedNetworkServerClient <BaseGameServerPayload, BaseGameClientPayload> client, SessionDetails details) { return(ManagedClientSessionFactory.Create(new ManagedClientSessionCreationContext(client, details))); }
/// <inheritdoc /> protected override ManagedClientSession <AuthenticationServerPayload, AuthenticationClientPayload> CreateIncomingSession(IManagedNetworkServerClient <AuthenticationServerPayload, AuthenticationClientPayload> client, SessionDetails details) { return(new AuthServerClientSession(client, details, ServiceContainer.Resolve <MessageHandlerService <AuthenticationClientPayload, AuthenticationServerPayload, IPeerSessionMessageContext <AuthenticationServerPayload> > >())); }
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); }
/// <inheritdoc /> public ManagedClientSessionCreationContext([NotNull] IManagedNetworkServerClient <GameServerPacketPayload, GameClientPacketPayload> client, [NotNull] SessionDetails details) { Client = client ?? throw new ArgumentNullException(nameof(client)); Details = details ?? throw new ArgumentNullException(nameof(details)); }
/// <inheritdoc /> protected override IManagedNetworkServerClient <PSOBBGamePacketPayloadServer, PSOBBGamePacketPayloadClient> BuildIncomingSessionManagedClient(NetworkClientBase clientBase, INetworkSerializationService serializeService) { ResetCrypto(); Logger.Info($"Client connecting to Proxy App with Listener: {this.ServerAddress.AddressEndpoint}:{this.ServerAddress.Port}"); IManagedNetworkServerClient <PSOBBGamePacketPayloadServer, PSOBBGamePacketPayloadClient> session = clientBase .AddCryptHandling(ClientEncryptionService, ClientDecryptionService) .AddBufferredWrite(4) .AddHeaderReading <PSOBBPacketHeader>(serializeService, 2) .AddNetworkMessageReading(serializeService) .For <PSOBBGamePacketPayloadClient, PSOBBGamePacketPayloadServer, IPacketPayload>(new PSOBBPacketHeaderFactory()) .AddReadBufferClearing() .Build() .AsManagedSession(); return(session); }
/// <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) { }