Ejemplo n.º 1
0
        public static WebSocketQactiveProvider Server(Uri uri, IWebSocketQactiveProviderTransportInitializer transportInitializer = null)
        {
            Contract.Requires(uri != null);
            Contract.Ensures(Contract.Result <WebSocketQactiveProvider>() != null);

            return(new WebSocketQactiveProvider(uri, transportInitializer));
        }
Ejemplo n.º 2
0
        public static IObservable <ClientTermination> ServeWebSocket <TSource>(
            this IQbservable <TSource> source,
            Uri uri,
            IWebSocketQactiveProviderTransportInitializer transportInitializer)
        {
            Contract.Requires(source != null);
            Contract.Requires(uri != null);
            Contract.Requires(transportInitializer != null);
            Contract.Ensures(Contract.Result <IObservable <ClientTermination> >() != null);

            return(WebSocketQbservableServer.CreateService <object, TSource>(uri, transportInitializer, _ => source));
        }
Ejemplo n.º 3
0
        public static IObservable <ClientTermination> CreateService <TSource, TResult>(
            Uri uri,
            IWebSocketQactiveProviderTransportInitializer transportInitializer,
            Func <IObservable <TSource>, IObservable <TResult> > service)
        {
            Contract.Requires(uri != null);
            Contract.Requires(transportInitializer != null);
            Contract.Requires(service != null);
            Contract.Ensures(Contract.Result <IObservable <ClientTermination> >() != null);

            return(QbservableServer.CreateService(WebSocketQactiveProvider.Server(uri, transportInitializer), service));
        }
Ejemplo n.º 4
0
        private WebSocketQactiveProvider(Uri uri, IWebSocketQactiveProviderTransportInitializer transportInitializer)
        {
            Contract.Requires(uri != null);

            Uri = uri;
            this.transportInitializer = transportInitializer;
            serverNumber = Interlocked.Increment(ref lastServerNumber);

            if (transportInitializer != null)
            {
                prepareSocket    = transportInitializer.Prepare;
                formatterFactory = () => transportInitializer.CreateFormatter() ?? WebSocketQactiveDefaults.CreateDefaultFormatter();
            }
            else
            {
                prepareSocket    = Nop.Action;
                formatterFactory = WebSocketQactiveDefaults.CreateDefaultFormatter;
            }
        }