当前位置: 首页>>代码示例>>C#>>正文


C# ResponseListener.OnError方法代码示例

本文整理汇总了C#中ConnectSdk.Windows.Service.Capability.Listeners.ResponseListener.OnError方法的典型用法代码示例。如果您正苦于以下问题:C# ResponseListener.OnError方法的具体用法?C# ResponseListener.OnError怎么用?C# ResponseListener.OnError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConnectSdk.Windows.Service.Capability.Listeners.ResponseListener的用法示例。


在下文中一共展示了ResponseListener.OnError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Seek

        public virtual void Seek(long position, ResponseListener listener)
        {
            IMediaControl mediaControl = null;

            if (Service != null)
                mediaControl = Service as IMediaControl;

            if (mediaControl != null)
                mediaControl.Seek(position, listener);
            else if (listener != null)
                listener.OnError(ServiceCommandError.NotSupported());
        }
开发者ID:DmitrySigaev,项目名称:Connect-SDK-Windows,代码行数:12,代码来源:WebAppSession.cs

示例2: GetVolume

        public void GetVolume(ResponseListener listener)
        {
            const string method = "GetVolume";
            const string instanceId = "0";
            const string channel = "Master";

            var parameters = new Dictionary<string, string> { { "Channel", channel } };

            var payload = GetMethodBody(RENDERING_CONTROL_URN, instanceId, method, parameters);

            var responseListener = new ResponseListener
            (
                loadEventArg =>
                {
                    var currentVolume = Util.ParseData((String)loadEventArg, "CurrentVolume");
                    var iVolume = 0;
                    try
                    {
                        iVolume = int.Parse(currentVolume);
                    }
                    // ReSharper disable once EmptyGeneralCatchClause
                    catch
                    {

                    }
                    var fVolume = (float)(iVolume / 100.0);

                    Util.PostSuccess(listener, fVolume);
                },
                serviceCommandError =>
                {
                    if (listener != null)
                        listener.OnError(serviceCommandError);
                }
            );

            var request = new ServiceCommand(this, method, payload, responseListener);
            request.Send();
        }
开发者ID:DmitrySigaev,项目名称:Connect-SDK-Windows,代码行数:39,代码来源:DlnaService.cs

示例3: UnPinWebApp

        public void UnPinWebApp(string webAppId, ResponseListener listener)
        {
            if (string.IsNullOrEmpty(webAppId))
            {
                if (listener != null)
                {
                    listener.OnError(new ServiceCommandError(-1, "You must provide a valid web app id"));
                }
                return;
            }

            const string uri = "ssap://webapp/removePinnedWebApp";
            var payload = new JsonObject();

            try
            {
                payload.Add("webAppId", JsonValue.CreateStringValue(webAppId));
            }
            // ReSharper disable once EmptyGeneralCatchClause
            catch (Exception)
            {

            }

            var responseListener = new ResponseListener
            (
                loadEventArg =>
                {
                    var loadEventArgs = loadEventArg as LoadEventArgs;
                    if (loadEventArgs == null) return;
                    var jsonObj = (JsonObject)(loadEventArgs.Load.GetPayload());
                    if (jsonObj.ContainsKey("pairingType"))
                    {
                        NotifyPairingRequired();
                    }
                    else
                    {
                        listener.OnSuccess(loadEventArg);
                    }
                },
                serviceCommandError => Util.PostError(listener, serviceCommandError)
            );

            ServiceCommand request = new UrlServiceSubscription(this, uri, payload, true, responseListener);
            request.Send();
        }
开发者ID:DmitrySigaev,项目名称:Connect-SDK-Windows,代码行数:46,代码来源:WebOsTvService.cs

示例4: DisplayImage

        public void DisplayImage(string url, string mimeType, string title, string description, string iconSrc,
            ResponseListener listener)
        {
            if (ServiceDescription.Version != null && ServiceDescription.Version.Equals("4.0.0"))
            {
                var dlnaService = GetDlnaService();

                if (dlnaService != null)
                {
                    var mediaPlayer = dlnaService.GetApi<IMediaPlayer>();

                    if (mediaPlayer != null)
                    {
                        mediaPlayer.DisplayImage(url, mimeType, title, description, iconSrc, listener);
                        return;
                    }
                }

                JsonObject ps = null;
                try
                {

                    ps = new JsonObject
                    {
                        {"target", JsonValue.CreateStringValue(url)},
                        {"title", JsonValue.CreateStringValue(title ?? string.Empty)},
                        {"description", JsonValue.CreateStringValue(description ?? string.Empty)},
                        {"mimeType", JsonValue.CreateStringValue(mimeType ?? string.Empty)},
                        {"iconSrc", JsonValue.CreateStringValue(iconSrc ?? string.Empty)},
                    };
                }
                catch (Exception ex)
                {
                    Util.PostError(listener, new ServiceCommandError(-1, ex.Message));
                }

                if (ps != null)
                    DisplayMedia(ps, listener);
            }
            else
            {
                const string webAppId = "MediaPlayer";
                var webAppLaunchListener = new ResponseListener
                    (
                        loadEventArg =>
                        {
                            var loadEventArgs = loadEventArg as LoadEventArgs;
                            if (loadEventArgs != null)
                            {
                                var webAppSession = (loadEventArgs.Load.GetPayload()) as WebAppSession;
                                if (webAppSession != null)
                                    webAppSession.DisplayImage(url, mimeType, title, description, iconSrc, listener);
                            }
                        },
                        serviceCommandError =>
                        {
                            listener.OnError(serviceCommandError);
                        });

                var webappResponseListener = new ResponseListener
                    (
                        loadEventArg =>
                        {
                            var loadEventArgs = loadEventArg as LoadEventArgs;
                            if (loadEventArgs != null)
                            {
                                var webAppSession = (loadEventArgs.Load.GetPayload()) as WebAppSession;
                                if (webAppSession != null)
                                    webAppSession.DisplayImage(url, mimeType, title, description, iconSrc, listener);
                            }
                        },
                        serviceCommandError =>
                        {
                            GetWebAppLauncher().LaunchWebApp(webAppId, webAppLaunchListener);
                        });

                GetWebAppLauncher().JoinWebApp(webAppId, webappResponseListener);
            }
        }
开发者ID:DmitrySigaev,项目名称:Connect-SDK-Windows,代码行数:79,代码来源:WebOsTvService.cs

示例5: Connect

        private void Connect(bool joinOnly, ResponseListener connectionListener)
        {
            if (Socket != null && Socket.State == State.Connecting)
            {
                if (connectionListener != null)
                    connectionListener.OnError(new ServiceCommandError(0,
                        "You have a connection request pending,  please wait until it has finished"));
                return;
            }

            if (IsConnected())
            {
                if (connectionListener != null)
                    connectionListener.OnSuccess(null);
                return;
            }

            MConnectionListener = new ResponseListener
            (
                loadEventArg =>
                {
                    var finalConnectionListener = new ResponseListener
                    (
                        loadEventArg2 =>
                        {
                            Connected = true;

                            if (connectionListener != null)
                                connectionListener.OnSuccess(loadEventArg2);
                        },
                        serviceCommandError =>
                        {
                            DisconnectFromWebApp();

                            if (connectionListener != null)
                                connectionListener.OnError(serviceCommandError);
                        }
                    );

                    Service.ConnectToWebApp(this, joinOnly, finalConnectionListener);
                },
                serviceCommandError =>
                {
                    if (Socket != null)
                        DisconnectFromWebApp();

                    if (connectionListener != null)
                    {
                        if (serviceCommandError == null)
                            serviceCommandError = new ServiceCommandError(0, "Unknown error connecting to web app");

                        connectionListener.OnError(serviceCommandError);
                    }
                }
            );

            if (Socket != null)
            {
                if (Socket.IsConnected())
                    MConnectionListener.OnSuccess(null);
                else
                    Socket.Connect();
            }
            else
            {
                //var uri = WebOstvServiceSocketClient.GetUri(Service);
                //Socket = new WebOstvServiceSocketClient(Service, uri);
                //Socket.Listener = mSocketListener;
                //Socket.Connect();

                var uri = WebOstvServiceSocketClient.GetUri(Service);
                if (WebOstvServiceSocketClient.SocketCache.ContainsKey(uri.ToString()))
                {
                    Socket = WebOstvServiceSocketClient.SocketCache[uri.ToString()];
                    if (mSocketListener != null)
                    {
                        Socket.Listener = mSocketListener;
                    }
                    if (Socket.IsConnected())
                        MConnectionListener.OnSuccess(null);
                    else
                    {
                        Socket.Connect();
                    }
                    //MConnectionListener.OnSuccess(null);
                }
                else
                {
                    Socket = new WebOstvServiceSocketClient(Service, uri)
                    {
                        Listener = mSocketListener
                    };
                    Socket.Connect();
                    WebOstvServiceSocketClient.SocketCache.Add(uri.ToString(), Socket);
                }
            }
        }
开发者ID:DmitrySigaev,项目名称:Connect-SDK-Windows,代码行数:97,代码来源:WebOsWebAppSession.cs

示例6: PostError

 public static void PostError(ResponseListener listener, ServiceCommandError error)
 {
     if (listener == null)
         return;
     listener.OnError(error);
 }
开发者ID:DmitrySigaev,项目名称:Connect-SDK-Windows,代码行数:6,代码来源:Util.cs

示例7: FastForward

        public void FastForward(ResponseListener listener)
        {
            IMediaControl mediaControl = null;

            if (Service != null)
                mediaControl = Service as IMediaControl;

            if (mediaControl != null)
                mediaControl.FastForward(listener);
            else if (listener != null)
                listener.OnError(ServiceCommandError.NotSupported());
        }
开发者ID:DmitrySigaev,项目名称:Connect-SDK-Windows,代码行数:12,代码来源:WebAppSession.cs

示例8: Seek

        public override void Seek(long position, ResponseListener listener)
        {
            if (position < 0)
            {
                if (listener != null)
                    listener.OnError(new ServiceCommandError(0, null));

                return;
            }

            var requestIdNumber = GetNextId();
            var requestId = String.Format("req{0}", requestIdNumber);

            JsonObject message = null;
            try
            {
                message = new JsonObject {{"contentType", JsonValue.CreateStringValue(NamespaceKey + "mediaCommand")}};
                var mediaCommandObject = new JsonObject
                {
                    {"type", JsonValue.CreateStringValue("seek")},
                    {"position", JsonValue.CreateNumberValue((int)(position/1000))},
                    {"requestId", JsonValue.CreateStringValue(requestId)}
                };
                message.Add("mediaCommand", mediaCommandObject);
            }
            catch (Exception)
            {
                if (listener != null)
                    listener.OnError(new ServiceCommandError(0, null));
            }

            var command = new ServiceCommand(null, null, null, listener);

            mActiveCommands.TryAdd(requestId, command);

            SendMessage(message, listener);
        }
开发者ID:DmitrySigaev,项目名称:Connect-SDK-Windows,代码行数:37,代码来源:WebOsWebAppSession.cs

示例9: SubscribeWebAppStatus

        public IServiceSubscription SubscribeWebAppStatus(ResponseListener listener)
        {
            if (listener != null)
                listener.OnError(ServiceCommandError.NotSupported());

            return null;
        }
开发者ID:DmitrySigaev,项目名称:Connect-SDK-Windows,代码行数:7,代码来源:WebAppSession.cs

示例10: Close

 public virtual void Close(ResponseListener listener)
 {
     if (listener != null)
         listener.OnError(ServiceCommandError.NotSupported());
 }
开发者ID:DmitrySigaev,项目名称:Connect-SDK-Windows,代码行数:5,代码来源:WebAppSession.cs

示例11: SubscribePlayState

        public virtual IServiceSubscription SubscribePlayState(ResponseListener listener)
        {
            IMediaControl mediaControl = null;

            if (Service != null)
                mediaControl = Service as IMediaControl;

            if (mediaControl != null)
                return mediaControl.SubscribePlayState(listener);
            if (listener != null)
                listener.OnError(ServiceCommandError.NotSupported());

            return null;
        }
开发者ID:DmitrySigaev,项目名称:Connect-SDK-Windows,代码行数:14,代码来源:WebAppSession.cs

示例12: SubscribeMediaInfo

 public IServiceSubscription SubscribeMediaInfo(ResponseListener listener)
 {
     listener.OnError(ServiceCommandError.NotSupported());
     return null;
 }
开发者ID:DmitrySigaev,项目名称:Connect-SDK-Windows,代码行数:5,代码来源:WebAppSession.cs

示例13: SendMessage

 public virtual void SendMessage(JsonObject message, ResponseListener listener)
 {
     if (listener != null)
     {
         listener.OnError(ServiceCommandError.NotSupported());
     }
 }
开发者ID:DmitrySigaev,项目名称:Connect-SDK-Windows,代码行数:7,代码来源:WebAppSession.cs

示例14: GetPosition

        public override void GetPosition(ResponseListener listener)
        {
            var requestIdNumber = GetNextId();
            var requestId = String.Format("req{0}", requestIdNumber);

            JsonObject message = null;
            try
            {
                message = new JsonObject {{"contentType", JsonValue.CreateStringValue(NamespaceKey + "mediaCommand")}};
                var mediaCommandObject = new JsonObject
                {
                    {"type", JsonValue.CreateStringValue("getPosition")},
                    {"requestId", JsonValue.CreateStringValue(requestId)}
                };
                message.Add("mediaCommand", mediaCommandObject);
            }
            catch (Exception)
            {
                if (listener != null)
                    listener.OnError(new ServiceCommandError(0, null));
            }

            var commandResponseListener = new ResponseListener
            (
                loadEventArg =>
                {
                    try
                    {
                        var position = ((loadEventArg as LoadEventArgs).Load.GetPayload() as JsonObject).GetNamedNumber("position");

                        if (listener != null)
                            listener.OnSuccess(position * 1000);
                    }
                    catch (Exception)
                    {
                        if (listener != null) listener.OnError(new ServiceCommandError(0, null));
                    }
                },
                serviceCommandError =>
                {
                    if (listener != null)
                        listener.OnError(serviceCommandError);
                }
            );

            var command = new ServiceCommand(null, null, null, commandResponseListener);
            mActiveCommands.TryAdd(requestId, command);

            var messageResponseListener = new ResponseListener
            (
                loadEventArg =>
                {

                },
                serviceCommandError =>
                {
                    if (listener != null)
                        listener.OnError(serviceCommandError);
                }
            );

            SendMessage(message, messageResponseListener);
        }
开发者ID:DmitrySigaev,项目名称:Connect-SDK-Windows,代码行数:63,代码来源:WebOsWebAppSession.cs

示例15: VolumeUp

        public void VolumeUp(ResponseListener listener)
        {
            var responseListener = new ResponseListener
            (
                loadEventArg =>
                {
                    var volume = (float)loadEventArg;
                    if (volume >= 1.0)
                    {
                        if (listener != null)
                        {
                            listener.OnSuccess(loadEventArg);
                        }
                    }
                    else
                    {
                        var newVolume = (float)(volume + 0.01);

                        if (newVolume > 1.0)
                            newVolume = (float)1.0;

                        SetVolume(newVolume, listener);

                        Util.PostSuccess(listener, null);
                    }
                },
                serviceCommandError =>
                {
                    if (listener != null)
                        listener.OnError(serviceCommandError);
                }
            );

            GetVolume(responseListener);
        }
开发者ID:DmitrySigaev,项目名称:Connect-SDK-Windows,代码行数:35,代码来源:DlnaService.cs


注:本文中的ConnectSdk.Windows.Service.Capability.Listeners.ResponseListener.OnError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。