/// <summary>
        /// Hosts a WAMP meta-api service describing the given realm.
        /// </summary>
        /// <param name="hostedRealm">The given realm.</param>
        /// <returns>A disposable: disposing it will unregister the hosted meta-api service.</returns>
        public static IDisposable HostMetaApiService(this IWampHostedRealm hostedRealm)
        {
            WampRealmDescriptorService service = new WampRealmDescriptorService(hostedRealm);

            CompositeDisposable disposable =
                HostDisposableService(hostedRealm, service, CalleeRegistrationInterceptor.Default);

            BrokerFeatures brokerFeatures = hostedRealm.Roles.Broker.Features;
            DealerFeatures dealerFeatures = hostedRealm.Roles.Dealer.Features;

            brokerFeatures.SessionMetaApi      = true;
            brokerFeatures.SubscriptionMetaApi = true;
            dealerFeatures.SessionMetaApi      = true;
            dealerFeatures.RegistrationMetaApi = true;

            IDisposable featureDisposable = Disposable.Create(() =>
            {
                brokerFeatures.SessionMetaApi      = null;
                brokerFeatures.SubscriptionMetaApi = null;
                dealerFeatures.SessionMetaApi      = null;
                dealerFeatures.RegistrationMetaApi = null;
            });

            disposable.Add(featureDisposable);

            return(disposable);
        }
Esempio n. 2
0
        /// <summary>
        /// Hosts a WAMP meta-api service describing the given realm.
        /// </summary>
        /// <param name="hostedRealm">The given realm.</param>
        /// <returns>A disposable: disposing it will unregister the hosted meta-api service.</returns>
        public static IDisposable HostMetaApiService(this IWampHostedRealm hostedRealm)
        {
            WampRealmDescriptorService service = new WampRealmDescriptorService(hostedRealm);

            Task <IAsyncDisposable> registrationDisposable =
                hostedRealm.Services.RegisterCallee(service);

            IAsyncDisposable asyncDisposable = registrationDisposable.Result;

            IDisposable unregisterDisposable =
                Disposable.Create(() => asyncDisposable.DisposeAsync().Wait());

            CompositeDisposable result =
                new CompositeDisposable(unregisterDisposable, service);

            return(result);
        }