本文整理汇总了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());
}
示例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();
}
示例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();
}
示例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);
}
}
示例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);
}
}
}
示例6: PostError
public static void PostError(ResponseListener listener, ServiceCommandError error)
{
if (listener == null)
return;
listener.OnError(error);
}
示例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());
}
示例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);
}
示例9: SubscribeWebAppStatus
public IServiceSubscription SubscribeWebAppStatus(ResponseListener listener)
{
if (listener != null)
listener.OnError(ServiceCommandError.NotSupported());
return null;
}
示例10: Close
public virtual void Close(ResponseListener listener)
{
if (listener != null)
listener.OnError(ServiceCommandError.NotSupported());
}
示例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;
}
示例12: SubscribeMediaInfo
public IServiceSubscription SubscribeMediaInfo(ResponseListener listener)
{
listener.OnError(ServiceCommandError.NotSupported());
return null;
}
示例13: SendMessage
public virtual void SendMessage(JsonObject message, ResponseListener listener)
{
if (listener != null)
{
listener.OnError(ServiceCommandError.NotSupported());
}
}
示例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);
}
示例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);
}