public PrivateServer(PrivateServerHubConnection <TransporterHub> connection, ServerUri serverUri)
        {
            this.connection = connection;
            this.serverUri  = serverUri;

            if (connection == null)
            {
                throw new NullReferenceException(nameof(connection));
            }

            connection.HubConnection = new HubConnectionBuilder().WithUrl(connection.HubUrl).WithAutomaticReconnect().Build();

            connection.HubConnection.On(Strings.GetRequestPacket, (Func <HttpRequestPacket, TextMapCarrier, Task>)(async(packet, carrier) =>
            {
                var stream = connection.HubConnection.StreamAsync <byte[]>(Strings.SendRequestBody, packet.Id);
                await WebRequest(packet, carrier, async(s) =>
                {
                    await foreach (var ba in stream)
                    {
                        await s.WriteAsync(ba);
                    }
                }).ConfigureAwait(false);
            }));

            connection.HubConnection.On <HttpRequestPacket, byte[], TextMapCarrier>(Strings.WebRequest, (packet, body, carrier) => WebrequestTask(packet, body, carrier));
        }
        public PrivateSocketServer(PrivateServerHubConnection <SocketHub> connection, ServerUri serverUri, ConcurrentDictionary <Guid, SocketConnection> connectionDictionary)
        {
            this.connection           = connection;
            this.serverUri            = serverUri;
            this.connectionDictionary = connectionDictionary;

            if (connection == null)
            {
                throw new NullReferenceException(nameof(connection));
            }


            connection.HubConnection = new HubConnectionBuilder().WithUrl(connection.HubUrl).WithAutomaticReconnect().Build();

            connection.HubConnection.On <Guid, SocketPacket>(Strings.TransporterToServer, (guid, packet) => {
                if (connectionDictionary.ContainsKey(guid)) // TODO: WTF?
                {
                    connectionDictionary[guid].SocketWriter.Post(packet);
                }
            });
        }
        public HttpTransporterContext(HttpContext context, ServerUri serverUri)
        {
            this.context = context;

            this.socketManager = new TransportableWebSocketManager(context, serverUri);
        }
 public TransportableWebSocketManager(HttpContext context, ServerUri serverUri)
 {
     this.Context   = context;
     this.ServerUri = serverUri;
 }