示例#1
0
        /// <summary>
        /// Generate the Channels section of an AsyncApi schema.
        /// </summary>
        private Channels GenerateChannels(TypeInfo[] asyncApiTypes, ISchemaRepository schemaRepository)
        {
            var channels = new Channels();

            channels.AddRange(GenerateChannelsFromMethods(asyncApiTypes, schemaRepository));
            channels.AddRange(GenerateChannelsFromClasses(asyncApiTypes, schemaRepository));

            return(channels);
        }
示例#2
0
        protected virtual void OnStart(object sender, ProtocolEventArgs <Start> e)
        {
            TaskRunner = new TaskRunner(e.Message.MaxMessageRate)
            {
                OnExecute = StreamChannelData,
                OnError   = LogStreamingError
            };

            if (Client.Handler <IChannelStreamingProducer>().IsSimpleStreamer)
            {
                var channelMetadata = Simulator.GetChannelMetadata(e.Header)
                                      .Cast <ChannelMetadataRecord>()
                                      .ToList();

                Channels.Clear();
                Channels.AddRange(channelMetadata);

                Client.Handler <IChannelStreamingProducer>()
                .ChannelMetadata(e.Header, channelMetadata);

                foreach (var channel in channelMetadata.Select(ToChannelStreamingInfo))
                {
                    ChannelStreamingInfo.Add(channel);
                }

                TaskRunner.Start();
            }
        }
        public Task Connect(InterceptionMode mode, string socketPath = Defaults.FullSocketPath, CancellationToken cancellationToken = default)
        {
            Mode = mode;
            Channels.Clear();
            Channels.AddRange(Enum.GetValues(typeof(CodeChannel)).Cast<CodeChannel>());
            Filters.Clear();
            PriortyCodes = false;

            InterceptInitMessage initMessage = new InterceptInitMessage { InterceptionMode = mode };
            return Connect(initMessage, socketPath, cancellationToken);
        }
        public async Task<Channels> GetPersonalChannelList(InternalChannelItemQuery query, CancellationToken cancellationToken)
        {
             int? page = null;

            if (query.StartIndex.HasValue && query.Limit.HasValue)
            {
                page = 1 + (query.StartIndex.Value / query.Limit.Value) % query.Limit.Value;
            }

            var pChannels = Plugin.vc.vimeo_people_getSubscriptions(false, false, false, true, false);
            
            var channels = new Channels();
            channels.AddRange(from pchan in pChannels where pchan.subject_id != "778" && pchan.subject_id != "927" select Plugin.vc.vimeo_channels_getInfo(pchan.subject_id));

            return channels;
        }
        public async Task <Channels> GetPersonalChannelList(InternalChannelItemQuery query, CancellationToken cancellationToken)
        {
            int?page = null;

            if (query.StartIndex.HasValue && query.Limit.HasValue)
            {
                page = 1 + (query.StartIndex.Value / query.Limit.Value) % query.Limit.Value;
            }

            var pChannels = Plugin.vc.vimeo_people_getSubscriptions(false, false, false, true, false);

            var channels = new Channels();

            channels.AddRange(from pchan in pChannels where pchan.subject_id != "778" && pchan.subject_id != "927" select Plugin.vc.vimeo_channels_getInfo(pchan.subject_id));

            return(channels);
        }
        protected virtual void OnStartStreaming(object sender, ProtocolEventArgs <StartStreaming> e)
        {
            TaskRunner = new TaskRunner
            {
                OnExecute = StreamChannelData,
                OnError   = LogStreamingError
            };

            var channelMetadata = Simulator.GetChannelMetadata(e.Header)
                                  .Cast <ChannelMetadataRecord>()
                                  .ToList();

            Channels.Clear();
            Channels.AddRange(channelMetadata);

            Client.Handler <IChannelStreamingProducer>()
            .ChannelMetadata(e.Header, channelMetadata);

            TaskRunner.Start();
        }
示例#7
0
        public bool Init()
        {
            JObject response = Api("rtm.start");

            if (response["ok"].Value <bool>() == false)
            {
                throw new Exception((string)response["error"]);
            }
            TeamInfo = JsonConvert.DeserializeObject <TeamInfo>(response["team"].ToString(), JsonConverter);
            Channels = JsonConvert.DeserializeObject <List <Channel> >(response["channels"].ToString(), JsonConverter);
            Channels.AddRange(JsonConvert.DeserializeObject <List <Channel> >(response["groups"].ToString(), JsonConverter)); // Groups are glorified channels?
            Ims = JsonConvert.DeserializeObject <List <Im> >(response["ims"].ToString(), JsonConverter);                      // They're also channels, but with 'User's instead of 'Name's.

            Users          = JsonConvert.DeserializeObject <List <User> >(response["users"].ToString(), JsonConverter);
            Self           = Users.First(n => n.Id == response["self"]["id"].ToString());
            Url            = response["url"].ToString();
            PrimaryChannel = Channels.FirstOrDefault(n => n.IsGeneral);
            //TODO: Groups, Bots and IMs.
            return(true);
        }
        /// <summary>
        /// Establishes a connection to the given UNIX socket file
        /// </summary>
        /// <param name="mode">Interception mode</param>
        /// <param name="channels">Optional list of input channels where codes may be intercepted</param>
        /// <param name="filters">Optional list of codes that may be intercepted</param>
        /// <param name="priortyCodes">Define if priorty codes may be intercepted</param>
        /// <param name="socketPath">Path to the UNIX socket file</param>
        /// <param name="cancellationToken">Optional cancellation token</param>
        /// <returns>Asynchronous task</returns>
        /// <exception cref="IncompatibleVersionException">API level is incompatible</exception>
        /// <exception cref="IOException">Connection mode is unavailable</exception>
        /// <exception cref="OperationCanceledException">Operation has been cancelled</exception>
        /// <exception cref="SocketException">Init message could not be processed</exception>
        public Task Connect(InterceptionMode mode, IEnumerable<CodeChannel> channels = null, IEnumerable<string> filters = null, bool priortyCodes = false, string socketPath = Defaults.FullSocketPath, CancellationToken cancellationToken = default)
        {
            Mode = mode;
            Channels.Clear();
            if (channels == null)
            {
                Channels.AddRange(Enum.GetValues(typeof(CodeChannel)).Cast<CodeChannel>());
            }
            else
            {
                Channels.AddRange(channels);
            }
            Filters.Clear();
            if (filters != null)
            {
                Filters.AddRange(filters);
            }
            PriortyCodes = priortyCodes;

            InterceptInitMessage initMessage = new InterceptInitMessage { InterceptionMode = mode, Channels = Channels, Filters = Filters, PriortyCodes = priortyCodes };
            return Connect(initMessage, socketPath, cancellationToken);
        }
 private void UpdateLiveChannels(IEnumerable <Channel> channels)
 {
     Channels.Clear();
     Channels.AddRange(channels.Select(channel => new LiveChannel(channel)));
 }