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


Java LaunchSession.getSessionType方法代码示例

本文整理汇总了Java中com.connectsdk.service.sessions.LaunchSession.getSessionType方法的典型用法代码示例。如果您正苦于以下问题:Java LaunchSession.getSessionType方法的具体用法?Java LaunchSession.getSessionType怎么用?Java LaunchSession.getSessionType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.connectsdk.service.sessions.LaunchSession的用法示例。


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

示例1: closeLaunchSession

import com.connectsdk.service.sessions.LaunchSession; //导入方法依赖的package包/类
/**
 * Closes the session on the first screen device. Depending on the sessionType, the associated service will have different ways of handling the close functionality.
 *
 * @param launchSession LaunchSession to close
 * @param listener (optional) listener to be called on success/failure
 */
public void closeLaunchSession(LaunchSession launchSession, ResponseListener<Object> listener) {
    if (launchSession == null) {
        Util.postError(listener, new ServiceCommandError(0, "You must provide a valid LaunchSession", null));
        return;
    }

    DeviceService service = launchSession.getService();
    if (service == null) {
        Util.postError(listener, new ServiceCommandError(0, "There is no service attached to this launch session", null));
        return;
    }

    switch (launchSession.getSessionType()) {
    case App:
        if (service instanceof Launcher)
            ((Launcher) service).closeApp(launchSession, listener);
        break;
    case Media:
        if (service instanceof MediaPlayer)
            ((MediaPlayer) service).closeMedia(launchSession, listener);
        break;
    case ExternalInputPicker:
        if (service instanceof ExternalInputControl)
            ((ExternalInputControl) service).closeInputPicker(launchSession, listener);
        break;
    case WebApp:
        if (service instanceof WebAppLauncher)
            ((WebAppLauncher) service).closeWebApp(launchSession, listener);
        break;
    case Unknown:
    default:
        Util.postError(listener, new ServiceCommandError(0, "This DeviceService does not know ho to close this LaunchSession", null));
        break;
    }
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:42,代码来源:DeviceService.java

示例2: closeLaunchSession

import com.connectsdk.service.sessions.LaunchSession; //导入方法依赖的package包/类
@Override
public void closeLaunchSession(LaunchSession launchSession, ResponseListener<Object> listener) {
    if (launchSession.getSessionType() == LaunchSessionType.App) {
        this.getLauncher().closeApp(launchSession, listener);
    } else
    {
        Util.postError(listener, new ServiceCommandError(-1, "Could not find a launcher associated with this LaunchSession", launchSession));
    }
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:10,代码来源:DIALService.java

示例3: sendMessage

import com.connectsdk.service.sessions.LaunchSession; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private void sendMessage(Object message, LaunchSession launchSession, ResponseListener<Object> listener) {
    if (launchSession == null || launchSession.getAppId() == null) {
        Util.postError(listener, new ServiceCommandError(0, "Must provide a valid LaunchSession object", null));
        return;
    }

    if (message == null) {
        Util.postError(listener, new ServiceCommandError(0, "Cannot send a null message", null));
        return;
    }

    if (socket == null) {
        connect();
    }

    String appId = launchSession.getAppId();
    String fullAppId = appId;

    if (launchSession.getSessionType() == LaunchSessionType.WebApp)
        fullAppId = mAppToAppIdMappings.get(appId);

    if (fullAppId == null || fullAppId.length() == 0) {
        Util.postError(listener, new ServiceCommandError(-1, "You must provide a valid LaunchSession to send messages to", null));

        return;
    }

    JSONObject payload = new JSONObject();

    try {
        payload.put("type", "p2p");
        payload.put("to", fullAppId);
        payload.put("payload", message);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(this, null, payload, true, listener);
    sendCommand(request);
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:42,代码来源:WebOSTVService.java


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