示例#1
0
        private void initializeChannels()
        {
            var req = new ListChannelsRequest();

            var joinDefaults = JoinedChannels.Count == 0;

            req.Success += channels =>
            {
                foreach (var channel in channels)
                {
                    var ch = getChannel(channel, addToAvailable: true);

                    // join any channels classified as "defaults"
                    if (joinDefaults && defaultChannels.Any(c => c.Equals(channel.Name, StringComparison.OrdinalIgnoreCase)))
                    {
                        JoinChannel(ch);
                    }
                }
            };
            req.Failure += error =>
            {
                Logger.Error(error, "Fetching channel list failed");
                initializeChannels();
            };

            api.Queue(req);
        }
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonMediaPackageConfig config = new AmazonMediaPackageConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonMediaPackageClient client = new AmazonMediaPackageClient(creds, config);

            ListChannelsResponse resp = new ListChannelsResponse();

            do
            {
                ListChannelsRequest req = new ListChannelsRequest
                {
                    NextToken = resp.NextToken
                    ,
                    MaxResults = maxItems
                };

                resp = client.ListChannels(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.Channels)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
示例#3
0
        private void initializeChannels()
        {
            loading.Show();

            messageRequest?.Cancel();

            ListChannelsRequest req = new ListChannelsRequest();

            req.Success += delegate(List <Channel> channels)
            {
                Scheduler.Add(delegate
                {
                    addChannel(channels.Find(c => c.Name == @"#lazer"));
                    addChannel(channels.Find(c => c.Name == @"#osu"));
                    addChannel(channels.Find(c => c.Name == @"#lobby"));

                    channelSelection.OnRequestJoin  = addChannel;
                    channelSelection.OnRequestLeave = removeChannel;
                    channelSelection.Sections       = new[]
                    {
                        new ChannelSection
                        {
                            Header   = "All Channels",
                            Channels = channels,
                        },
                    };
                });

                messageRequest = Scheduler.AddDelayed(fetchNewMessages, 1000, true);
            };

            api.Queue(req);
        }
示例#4
0
        /// <summary>
        /// Returns a collection of Channels.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the ListChannels service method.</param>
        ///
        /// <returns>The response from the ListChannels service method, as returned by MediaPackage.</returns>
        /// <exception cref="Amazon.MediaPackage.Model.ForbiddenException">
        /// The client is not authorized to access the requested resource.
        /// </exception>
        /// <exception cref="Amazon.MediaPackage.Model.InternalServerErrorException">
        /// An unexpected error occurred.
        /// </exception>
        /// <exception cref="Amazon.MediaPackage.Model.NotFoundException">
        /// The requested resource does not exist.
        /// </exception>
        /// <exception cref="Amazon.MediaPackage.Model.ServiceUnavailableException">
        /// An unexpected error occurred.
        /// </exception>
        /// <exception cref="Amazon.MediaPackage.Model.TooManyRequestsException">
        /// The client has exceeded their resource or throttling limits.
        /// </exception>
        /// <exception cref="Amazon.MediaPackage.Model.UnprocessableEntityException">
        /// The parameters sent in the request are not valid.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/mediapackage-2017-10-12/ListChannels">REST API Reference for ListChannels Operation</seealso>
        public virtual ListChannelsResponse ListChannels(ListChannelsRequest request)
        {
            var marshaller   = ListChannelsRequestMarshaller.Instance;
            var unmarshaller = ListChannelsResponseUnmarshaller.Instance;

            return(Invoke <ListChannelsRequest, ListChannelsResponse>(request, marshaller, unmarshaller));
        }
示例#5
0
文件: ChatOverlay.cs 项目: pujitm/osu
        private void initializeChannels()
        {
            loading.Show();

            messageRequest?.Cancel();

            ListChannelsRequest req = new ListChannelsRequest();

            req.Success += delegate(List <Channel> channels)
            {
                AvailableChannels = channels;

                Scheduler.Add(delegate
                {
                    //todo: decide how to handle default channels for a user now that they are saved server-side.
                    addChannel(channels.Find(c => c.Name == @"#lazer"));
                    addChannel(channels.Find(c => c.Name == @"#osu"));

                    channelSelection.OnRequestJoin  = addChannel;
                    channelSelection.OnRequestLeave = removeChannel;
                    channelSelection.Sections       = new[]
                    {
                        new ChannelSection
                        {
                            Header   = "All Channels",
                            Channels = channels,
                        },
                    };
                });

                messageRequest = Scheduler.AddDelayed(fetchUpdates, 1000, true);
            };

            api.Queue(req);
        }
示例#6
0
        private void initializeChannels()
        {
            SpriteText loading;

            Add(loading = new OsuSpriteText
            {
                Text     = @"initialising chat...",
                Anchor   = Anchor.Centre,
                Origin   = Anchor.Centre,
                TextSize = 40,
            });

            messageRequest?.Cancel();

            ListChannelsRequest req = new ListChannelsRequest();

            req.Success += delegate(List <Channel> channels)
            {
                Scheduler.Add(delegate
                {
                    loading.FadeOut(100);
                    loading.Expire();

                    addChannel(channels.Find(c => c.Name == @"#lazer"));
                    addChannel(channels.Find(c => c.Name == @"#osu"));
                    addChannel(channels.Find(c => c.Name == @"#lobby"));
                });

                messageRequest = Scheduler.AddDelayed(fetchNewMessages, 1000, true);
            };

            api.Queue(req);
        }
示例#7
0
        /// <summary>
        /// Lists all the Channels that match the specified filters.
        /// </summary>
        /// <param name="request">The request object containing the details to send. Required.</param>
        /// <param name="retryConfiguration">The retry configuration that will be used by to send this request. Optional.</param>
        /// <param name="cancellationToken">The cancellation token to cancel this operation. Optional.</param>
        /// <returns>A response object containing details about the completed operation</returns>
        /// <example>Click <a href="https://docs.cloud.oracle.com/en-us/iaas/tools/dot-net-examples/latest/mysql/ListChannels.cs.html">here</a> to see an example of how to use ListChannels API.</example>
        public async Task <ListChannelsResponse> ListChannels(ListChannelsRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called listChannels");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/channels".Trim('/')));
            HttpMethod         method         = new HttpMethod("GET");
            HttpRequestMessage requestMessage = Converter.ToHttpRequestMessage(uri, method, request);

            requestMessage.Headers.Add("Accept", "application/json");
            GenericRetrier      retryingClient = Retrier.GetPreferredRetrier(retryConfiguration, this.retryConfiguration);
            HttpResponseMessage responseMessage;

            try
            {
                if (retryingClient != null)
                {
                    responseMessage = await retryingClient.MakeRetryingCall(this.restClient.HttpSend, requestMessage, cancellationToken).ConfigureAwait(false);
                }
                else
                {
                    responseMessage = await this.restClient.HttpSend(requestMessage).ConfigureAwait(false);
                }
                this.restClient.CheckHttpResponseMessage(requestMessage, responseMessage);

                return(Converter.FromHttpResponseMessage <ListChannelsResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"ListChannels failed with error: {e.Message}");
                throw;
            }
        }
示例#8
0
        /// <summary>
        /// Initiates the asynchronous execution of the ListChannels operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the ListChannels operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/mediapackage-2017-10-12/ListChannels">REST API Reference for ListChannels Operation</seealso>
        public virtual Task <ListChannelsResponse> ListChannelsAsync(ListChannelsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = ListChannelsRequestMarshaller.Instance;
            var unmarshaller = ListChannelsResponseUnmarshaller.Instance;

            return(InvokeAsync <ListChannelsRequest, ListChannelsResponse>(request, marshaller,
                                                                           unmarshaller, cancellationToken));
        }
        /// <summary>
        /// Returns a collection of Channels.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the ListChannels service method.</param>
        ///
        /// <returns>The response from the ListChannels service method, as returned by MediaPackage.</returns>
        /// <exception cref="Amazon.MediaPackage.Model.ForbiddenException">
        /// The client is not authorized to access the requested resource.
        /// </exception>
        /// <exception cref="Amazon.MediaPackage.Model.InternalServerErrorException">
        /// An unexpected error occurred.
        /// </exception>
        /// <exception cref="Amazon.MediaPackage.Model.NotFoundException">
        /// The requested resource does not exist.
        /// </exception>
        /// <exception cref="Amazon.MediaPackage.Model.ServiceUnavailableException">
        /// An unexpected error occurred.
        /// </exception>
        /// <exception cref="Amazon.MediaPackage.Model.TooManyRequestsException">
        /// The client has exceeded their resource or throttling limits.
        /// </exception>
        /// <exception cref="Amazon.MediaPackage.Model.UnprocessableEntityException">
        /// The parameters sent in the request are not valid.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/mediapackage-2017-10-12/ListChannels">REST API Reference for ListChannels Operation</seealso>
        public virtual ListChannelsResponse ListChannels(ListChannelsRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = ListChannelsRequestMarshaller.Instance;
            options.ResponseUnmarshaller = ListChannelsResponseUnmarshaller.Instance;

            return(Invoke <ListChannelsResponse>(request, options));
        }
        /// <summary>
        /// Initiates the asynchronous execution of the ListChannels operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the ListChannels operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/mediapackage-2017-10-12/ListChannels">REST API Reference for ListChannels Operation</seealso>
        public virtual Task <ListChannelsResponse> ListChannelsAsync(ListChannelsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = ListChannelsRequestMarshaller.Instance;
            options.ResponseUnmarshaller = ListChannelsResponseUnmarshaller.Instance;

            return(InvokeAsync <ListChannelsResponse>(request, options, cancellationToken));
        }
示例#11
0
 /// <summary>
 /// Creates a new enumerable which will iterate over the responses received from the ListChannels operation. This enumerable
 /// will fetch more data from the server as needed.
 /// </summary>
 /// <param name="request">The request object containing the details to send</param>
 /// <param name="retryConfiguration">The configuration for retrying, may be null</param>
 /// <param name="cancellationToken">The cancellation token object</param>
 /// <returns>The enumerator, which supports a simple iteration over a collection of a specified type</returns>
 public IEnumerable <ListChannelsResponse> ListChannelsResponseEnumerator(ListChannelsRequest request, Common.Retry.RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
 {
     return(new Common.Utils.ResponseEnumerable <ListChannelsRequest, ListChannelsResponse>(
                response => response.OpcNextPage,
                input =>
     {
         if (!string.IsNullOrEmpty(input))
         {
             request.Page = input;
         }
         return request;
     },
                request => client.ListChannels(request, retryConfiguration, cancellationToken)
                ));
 }
示例#12
0
        private void initializeChannels()
        {
            if (api.State != APIAccess.APIState.Online)
            {
                return;
            }

            messageRequest?.Cancel();

            ListChannelsRequest req = new ListChannelsRequest();

            req.Success += delegate(List <Channel> channels)
            {
                this.channels  = channels;
                messageRequest = scheduler.AddDelayed(requestNewMessages, 1000, true);
            };
            api.Queue(req);
        }
示例#13
0
        private void initializeChannels()
        {
            careChannels = new List <Channel>();

            if (api.State != APIState.Online)
            {
                return;
            }

            Add(flow = new FlowContainer
            {
                RelativeSizeAxes = Axes.Both,
                Direction        = FlowDirection.VerticalOnly
            });

            SpriteText loading;

            Add(loading = new SpriteText
            {
                Text     = @"Loading available channels...",
                Anchor   = Anchor.Centre,
                Origin   = Anchor.Centre,
                TextSize = 40,
            });

            messageRequest?.Cancel();

            ListChannelsRequest req = new ListChannelsRequest();

            req.Success += delegate(List <Channel> channels)
            {
                Scheduler.Add(delegate
                {
                    loading.FadeOut(100);
                });

                addChannel(channels.Find(c => c.Name == @"#osu"));
                addChannel(channels.Find(c => c.Name == @"#lobby"));
                addChannel(channels.Find(c => c.Name == @"#english"));

                messageRequest = scheduler.AddDelayed(() => FetchNewMessages(api), 1000, true);
            };
            api.Queue(req);
        }
示例#14
0
文件: ChatOverlay.cs 项目: revam/osu
        private void initializeChannels()
        {
            Clear();

            careChannels = new List <Channel>();

            //if (api.State != APIAccess.APIState.Online)
            //  return;

            SpriteText loading;

            Add(loading = new OsuSpriteText
            {
                Text     = @"Loading available channels...",
                Anchor   = Anchor.Centre,
                Origin   = Anchor.Centre,
                TextSize = 40,
            });

            messageRequest?.Cancel();

            ListChannelsRequest req = new ListChannelsRequest();

            req.Success += delegate(List <Channel> channels)
            {
                Debug.Assert(careChannels.Count == 0);

                Scheduler.Add(delegate
                {
                    loading.FadeOut(100);
                    addChannel(channels.Find(c => c.Name == @"#osu"));
                });

                //addChannel(channels.Find(c => c.Name == @"#lobby"));
                //addChannel(channels.Find(c => c.Name == @"#english"));

                messageRequest = Scheduler.AddDelayed(() => FetchNewMessages(api), 1000, true);
            };
            api.Queue(req);
        }
示例#15
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListChannelsRequest request;

            try
            {
                request = new ListChannelsRequest
                {
                    CompartmentId  = CompartmentId,
                    OpcRequestId   = OpcRequestId,
                    DbSystemId     = DbSystemId,
                    ChannelId      = ChannelId,
                    DisplayName    = DisplayName,
                    LifecycleState = LifecycleState,
                    IsEnabled      = IsEnabled,
                    SortBy         = SortBy,
                    SortOrder      = SortOrder,
                    Limit          = Limit,
                    Page           = Page
                };
                IEnumerable <ListChannelsResponse> responses = GetRequestDelegate().Invoke(request);
                foreach (var item in responses)
                {
                    response = item;
                    WriteOutput(response, response.Items, true);
                }
                if (!ParameterSetName.Equals(AllPageSet) && !ParameterSetName.Equals(LimitSet) && response.OpcNextPage != null)
                {
                    WriteWarning("This operation supports pagination and not all resources were returned. Re-run using the -All option to auto paginate and list all resources.");
                }
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
示例#16
0
        private void initializeChannels()
        {
            careChannels = new List<Channel>();

            if (api.State != APIState.Online)
                return;

            Add(flow = new FlowContainer
            {
                RelativeSizeAxes = Axes.Both,
                Direction = FlowDirection.VerticalOnly
            });

            SpriteText loading;
            Add(loading = new SpriteText
            {
                Text = @"Loading available channels...",
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                TextSize = 40,
            });

            messageRequest?.Cancel();

            ListChannelsRequest req = new ListChannelsRequest();
            req.Success += delegate (List<Channel> channels)
            {
                Scheduler.Add(delegate
                {
                    loading.FadeOut(100);
                });

                addChannel(channels.Find(c => c.Name == @"#osu"));
                addChannel(channels.Find(c => c.Name == @"#lobby"));
                addChannel(channels.Find(c => c.Name == @"#english"));

                messageRequest = scheduler.AddDelayed(() => FetchNewMessages(api), 1000, true);
            };
            api.Queue(req);
        }
示例#17
0
文件: ChatOverlay.cs 项目: yheno/osu
        private void initializeChannels()
        {
            Clear();

            careChannels = new List<Channel>();

            //if (api.State != APIAccess.APIState.Online)
            //  return;

            SpriteText loading;
            Add(loading = new SpriteText
            {
                Text = @"Loading available channels...",
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                TextSize = 40,
            });

            messageRequest?.Cancel();

            ListChannelsRequest req = new ListChannelsRequest();
            req.Success += delegate (List<Channel> channels)
            {
                Scheduler.Add(delegate
                {
                    loading.FadeOut(100);
                    addChannel(channels.Find(c => c.Name == @"#osu"));
                });

                //addChannel(channels.Find(c => c.Name == @"#lobby"));
                //addChannel(channels.Find(c => c.Name == @"#english"));

                messageRequest = Scheduler.AddDelayed(() => FetchNewMessages(api), 1000, true);
            };
            api.Queue(req);
        }