Ejemplo n.º 1
0
        private void OnStartCore(object sender, VoidRequestEventArgs <v11.Protocol.ChannelStreaming.Start> args)
        {
            var handler   = (v11.Protocol.ChannelStreaming.IChannelStreamingProducer)sender;
            var sessionId = GetSessionId(handler);
            var callbacks = CreateChannelStreamingCallbacks(handler);

            if (Store.StartChannelSubscription(EtpVersion.v11, sessionId, args.Request.Body.MaxDataItems, TimeSpan.FromMilliseconds(args.Request.Body.MaxMessageRate), handler.Capabilities.SimpleStreamer ?? false, callbacks))
            {
                if (handler.Capabilities.SimpleStreamer ?? false)
                {
                    var describe = new v11.Protocol.ChannelStreaming.ChannelDescribe
                    {
                        Uris = new List <string> {
                            EtpUri.RootUri11
                        },
                    };
                    foreach (var subscription in describe.GetSubscriptions(sessionId)) // Register global metadata subscriptions
                    {
                        var subscriptionInfo = new MockSubscriptionInfo(subscription);
                        if (Store.HasChannelSubscriptionScope(sessionId, subscriptionInfo))
                        {
                            continue;
                        }

                        IList <MockObject> addedChannels;
                        if (Store.AddChannelSubscriptionChannelScope(sessionId, subscriptionInfo, out addedChannels))
                        {
                            var channels = addedChannels
                                           .Where(o => o is IMockGrowingObject)
                                           .Select(o => ((IMockGrowingObject)o).ChannelMetadataRecord11(Store.GetChannelId(sessionId, o)))
                                           .ToList();
                            handler.ChannelMetadata(subscription.RequestUuid, channels);
                        }
                    }
                }
            }
            else
            {
                args.FinalError = handler.ErrorInfo().RequestDenied();
            }
        }
Ejemplo n.º 2
0
        private void OnStartStreamingCore(object sender, VoidRequestEventArgs <v12.Protocol.ChannelStreaming.StartStreaming> args)
        {
            var handler   = (v12.Protocol.ChannelStreaming.IChannelStreamingProducer)sender;
            var sessionId = GetSessionId(handler);
            var callbacks = CreateChannelStreamingCallbacks(handler);

            if (Store.StartChannelSubscription(EtpVersion.v11, sessionId, int.MaxValue, TimeSpan.FromMilliseconds(0), true, callbacks))
            {
                var describe = new v11.Protocol.ChannelStreaming.ChannelDescribe
                {
                    Uris = new List <string> {
                        EtpUri.RootUri11
                    },
                };
                foreach (var subscription in describe.GetSubscriptions(sessionId)) // Register global metadata subscriptions
                {
                    var subscriptionInfo = new MockSubscriptionInfo(subscription);
                    if (Store.HasChannelSubscriptionScope(sessionId, subscriptionInfo))
                    {
                        continue;
                    }

                    IList <MockObject> addedChannels;
                    if (Store.AddChannelSubscriptionChannelScope(sessionId, subscriptionInfo, out addedChannels))
                    {
                        var channels = addedChannels
                                       .Where(o => o is MockChannel)
                                       .Select(o => ((MockChannel)o).ChannelMetadataRecord12(Store.GetChannelId(sessionId, o)))
                                       .ToList();
                        handler.ChannelMetadata(channels);
                    }
                }
            }
            else
            {
                args.FinalError = handler.ErrorInfo().RequestDenied();
            }
        }