コード例 #1
0
        public async Task CreateFilterWIthExistingSubscriptionId()
        {
            var client = new RtmClientBuilder(Config.Endpoint, Config.AppKey).Build();
            await client.StartAndWaitConnected();

            var channel = GenerateRandomChannelName();

            client.CreateSubscription(channel, SubscriptionModes.Advanced, null);

            var queue = client.CreateStateQueue();

            client.SetClientErrorObserver(queue);
            var subObserver = new TestSubscriptionObserverQueue(queue);

            subObserver.ObserveAll();

            client.CreateSubscription(
                channel,
                new SubscriptionConfig(SubscriptionModes.Advanced, observer: subObserver)
            {
                Filter = $"select * FROM `{channel}`"
            });

            await queue.AssertDequeue("rtm:subscribe-error:InvalidOperationException");

            await queue.AssertEmpty(client, millis : 200);

            await client.Dispose();
        }
コード例 #2
0
        public async Task CreateSubscriptionToRestrictedChannel()
        {
            var client = new RtmClientBuilder(Config.Endpoint, Config.AppKey).Build();
            await client.StartAndWaitConnected();

            var channel = Config.RestrictedChannel;

            var queue = client.CreateStateQueue();

            client.SetClientErrorObserver(queue);
            var subObserver = new TestSubscriptionObserverQueue(queue);

            subObserver.ObserveAll();

            client.CreateSubscription(channel, SubscriptionModes.Advanced, subObserver);

            await queue.AssertDequeue(
                "rtm:created",
                "rtm:enter-unsubscribed",
                "rtm:leave-unsubscribed",
                "rtm:enter-subscribing",
                "rtm:subscribe-error:SubscribeException:authorization_denied",
                "rtm:leave-subscribing",
                "rtm:enter-failed");

            await queue.AssertEmpty(client, millis : 200);

            await client.Dispose();
        }