public TServer Create(TRawClient client, IWampConnection <TMessage> connection)
        {
            IWampOutgoingMessageHandler handler =
                mOutgoingHandlerBuilder.Build(client, connection);

            WampOutgoingInterceptor <TMessage> interceptor =
                new WampOutgoingInterceptor <TMessage>(mOutgoingSerializer,
                                                       handler);

            ProxyGenerationOptions proxyOptions =
                new ProxyGenerationOptions()
            {
                Selector = new WampInterceptorSelector <TMessage>()
            };

            proxyOptions.AddMixinInstance(new DisposableForwarder(connection));

            TServer result =
                (TServer)mProxyGenerator.CreateInterfaceProxyWithoutTarget
                    (typeof(TServer),
                    new Type[] { typeof(IDisposable) },
                    proxyOptions, interceptor);

            return(result);
        }
        public TServer Create(TRawClient client, IWampConnection <TMessage> connection)
        {
            IWampOutgoingMessageHandler handler =
                mOutgoingHandlerBuilder.Build(client, connection);

            WampOutgoingInterceptor <TMessage> interceptor =
                new WampOutgoingInterceptor <TMessage>(mOutgoingSerializer,
                                                       handler);

            var proxyOptions = new ProxyGenerationOptions();

            TServer result =
                mProxyGenerator.CreateInterfaceProxyWithoutTarget <TServer>
                    (proxyOptions,
                    interceptor);

            return(result);
        }
Пример #3
0
        public IWampClient Create(IWampConnection <TMessage> connection)
        {
            WampOutgoingInterceptor <TMessage> wampOutgoingInterceptor =
                new WampOutgoingInterceptor <TMessage>
                    (mOutgoingSerializer,
                    mOutgoingHandlerBuilder.Build(connection));

            ProxyGenerationOptions proxyGenerationOptions =
                new ProxyGenerationOptions()
            {
                Selector =
                    new WampInterceptorSelector <TMessage>()
            };

            proxyGenerationOptions.AddMixinInstance
                (new WampClientContainerDisposable <TMessage, IWampClient>
                    (mContainer, connection));

            // This is specific to WAMPv1. In WAMPv2 I think no curies
            // will be supported.
            proxyGenerationOptions.AddMixinInstance(new WampCurieMapper());

            var monitor = new WampConnectionMonitor <TMessage>(connection);

            proxyGenerationOptions.AddMixinInstance(monitor);

            SessionIdPropertyInterceptor sessionIdPropertyInterceptor =
                new SessionIdPropertyInterceptor();

            IWampClient result =
                mGenerator.CreateInterfaceProxyWithoutTarget <IWampClient>
                    (proxyGenerationOptions, wampOutgoingInterceptor,
                    sessionIdPropertyInterceptor,
                    new WampCraAuthenticatorPropertyInterceptor());

            monitor.Client = result;

            object sessiondId = mContainer.GenerateClientId(result);

            sessionIdPropertyInterceptor.SessionId = (string)sessiondId;

            return(result);
        }
Пример #4
0
        public IWampClientProxy <TMessage> Create(IWampConnection <TMessage> connection)
        {
            IWampOutgoingMessageHandler outgoingHandler =
                mOutgoingHandlerBuilder.Build(connection);

            WampOutgoingInterceptor <TMessage> wampOutgoingInterceptor =
                new WampOutgoingInterceptor <TMessage>
                    (mOutgoingSerializer,
                    outgoingHandler);

            WampRawOutgoingInterceptor <TMessage> wampRawOutgoingInterceptor =
                new WampRawOutgoingInterceptor <TMessage>(outgoingHandler);

            ProxyGenerationOptions proxyGenerationOptions =
                new ProxyGenerationOptions()
            {
                Selector =
                    new WampInterceptorSelector <TMessage>()
            };

            WampConnectionMonitor <TMessage> monitor =
                new WampConnectionMonitor <TMessage>(connection);

            proxyGenerationOptions.AddMixinInstance(monitor);

            proxyGenerationOptions.AddMixinInstance
                (new WampClientContainerDisposable <TMessage, IWampClientProxy <TMessage> >
                    (mContainer, connection));

            WampTransportDetails transportDetails = null;


            if (connection is IDetailedWampConnection <TMessage> detailedConnection)
            {
                transportDetails = detailedConnection.TransportDetails;
            }

            WampClientPropertyBag <TMessage> propertyBag =
                new WampClientPropertyBag <TMessage>(mBinding, transportDetails);

            proxyGenerationOptions.AddMixinInstance(propertyBag);


            if (connection is IWampAuthenticatedConnection <TMessage> authenticatedConnection)
            {
                propertyBag.Authenticator = authenticatedConnection.Authenticator;
            }

            IWampClientProxy <TMessage> result =
                mGenerator.CreateInterfaceProxyWithoutTarget
                    (typeof(IWampProxy), new[] { typeof(IWampClientProxy <TMessage>) },
                    proxyGenerationOptions,
                    wampRawOutgoingInterceptor,
                    wampOutgoingInterceptor)
                as IWampClientProxy <TMessage>;

            monitor.Client = result;

            long session = (long)mContainer.GenerateClientId(result);

            propertyBag.Session = session;

            return(result);
        }