Exemplo n.º 1
0
        private void GetRequest(string uri, HTTPClientResponseCallback callback)
        {
            var request = new ServerRequest(IpAddress, uri, callback);
            var auth    = Convert.ToBase64String(Encoding.ASCII.GetBytes(_username + ":" + _password));

            request.Header.AddHeader(new HttpHeader("Authorization", "Basic " + auth));
            _server.QueueRequest(request);
        }
Exemplo n.º 2
0
        public void Discover()
        {
#if DEBUG
            Debug.WriteInfo("Discovering IPTV Receivers....");
#endif
            _server.QueueRequest(new ServerRequest(_server.HostNameOrIpAddress, "/api/control/devices?views=control,artiosign", Callback));
        }
Exemplo n.º 3
0
        public void UpdateChannels()
        {
#if DEBUG
            CrestronConsole.PrintLine("Getting IPTV Channel list ....");
#endif
            _server.QueueRequest(new ServerRequest(_server.HostNameOrIpAddress, "/api/channels/portal", Callback));
        }
Exemplo n.º 4
0
        public void StartRecording(string name, string description, DateTime startTime, DateTime endTime, string channelName, string channelIp, int channelPort)
        {
            var requestData = new
            {
                name,
                description,
                bitrate = 20000000,
                channel = new
                {
                    @channel = channelName,
                    address  = new
                    {
                        @ip   = channelIp,
                        @port = channelPort
                    }
                },
                schedule = new
                {
                    @start = startTime,
                    @stop  = endTime,
                }
            };
            var json    = JToken.FromObject(requestData);
            var request = new ServerRequest(_server.HostNameOrIpAddress, "/api/content/recording/scheduled",
                                            json.ToString(),
                                            (response, error) =>
            {
                if (error != HTTP_CALLBACK_ERROR.COMPLETED)
                {
                    CloudLog.Warn("Cannot communicate with AvediaServer to get recordings");
                    OnRecordingsUpdated(new RecordingsUpdatedEventArgs
                    {
                        EventType     = RecordingUpdatedEventType.StartRecording,
                        RequestFailed = true,
                        FailReason    = "Could not get response from server"
                    });
                    return;
                }

                if (response.Code != 201)
                {
                    CloudLog.Error("{0} HttpResponse = {1}", GetType().Name, response.Code);
                    OnRecordingsUpdated(new RecordingsUpdatedEventArgs
                    {
                        EventType     = RecordingUpdatedEventType.StartRecording,
                        RequestFailed = true,
                        FailReason    = "Server responded with " + response.Code + " error",
                    });
                    return;
                }

                var data = JToken.Parse(response.ContentString).First;

                var id = data["Id"].Value <int>();

                CloudLog.Error("{0} HttpResponse = {1}", GetType().Name, response.Code);
                OnRecordingsUpdated(new RecordingsUpdatedEventArgs
                {
                    EventType     = RecordingUpdatedEventType.StartRecording,
                    RequestFailed = false,
                    RecordingId   = id
                });
            });

            _server.QueueRequest(request);
        }