Пример #1
0
        void SendStop()
        {
            LiveCourseNotifyClient client = new LiveCourseNotifyClient();
            Uri url = client.Endpoint.Address.Uri;

            client.Endpoint.Address = new EndpointAddress(url.Scheme + "://" + config["cloud_ip"] + ":" + config["cloud_port"] + url.PathAndQuery);
            Log.log(string.Format("[LivingcastTask] SendStop: wsurl={0}\n", client.Endpoint.Address.ToString()));

            try {
                ZQNB.Gateway.LiveService.OperationResult result = client.NotifyRecordingStop(config["device_id"]);
                Log.log("\ten, success=" + result.Success + ", message=" + result.Message + "\n");
            }
            catch (CommunicationException) {
                client.Abort();
                Log.log("\tCommunicationException!\n");
            }
            catch (TimeoutException) {
                client.Abort();
                Log.log("\tTimeoutExeption!\n");
            }
            catch (Exception) {
                client.Abort();
                Log.log("\tException\n");
            }
            finally {
                if (client != null)
                {
                    client.Close();
                }
            }
        }
Пример #2
0
        void SendStart(string uuid)
        {
            LiveCourseNotifyClient client = new LiveCourseNotifyClient();
            Uri url = client.Endpoint.Address.Uri;

            client.Endpoint.Address = new EndpointAddress(url.Scheme + "://" + config["cloud_ip"] + ":" + config["cloud_port"] + url.PathAndQuery);
            Log.log(string.Format("[LivingcastTask] SendStart: wsurl={0}\n", client.Endpoint.Address.ToString()));
            Live live = new Live()
            {
                Title    = config["title"],
                Teacher  = config["teacher"],
                Owner    = config["teacher"] + "@" + config["domain"],
                Subject  = StartParam.subject,
                Grade    = config["grade"],
                Guid     = Guid.Parse(uuid),
                LiveUrls = new LiveUrl[1],
            };

            foreach (LivingcastStream s in Streams)
            {
                live.LiveUrls[0] = new LiveUrl()
                {
                    Url = s.RtmpURL,
                    Tag = s.Mode,
                };
            }

            try {
                ZQNB.Gateway.LiveService.OperationResult result = client.NotifyRecordingStart(live, config["device_id"]);
                Log.log("\ten, success=" + result.Success + ", message=" + result.Message);
            }
            catch (CommunicationException) {
                Log.log("\tCommunicationException\n");
                client.Abort();
            }
            catch (TimeoutException) {
                Log.log("\tTimeoutException\n");
                client.Abort();
            }
            catch (Exception) {
                Log.log("\tException\n");
                client.Abort();
            }
            finally {
                if (client != null)
                {
                    client.Close();
                }
            }
        }