Wuying Cloud Application web integration

更新时间:
复制 MD 格式

This guide describes how to integrate Wuying Cloud Application into a third-party web service. This integration lets you quickly build your own endpoint computing products based on Wuying Cloud Application and offer them to your end users.

1. Background

For an introduction to Wuying Cloud Application, see What is WUYING App Streaming. This guide is for developers who want to integrate Wuying Cloud Application into their web service.

2. Prerequisites

  • Prepare development resources.

    You need a web frontend and a backend server.

    Important

    A backend server is required. This solution does not support frontend-only integration.

  • Set up your account and permissions.

  • Obtain the required SDK and API information.

    • Familiarize yourself with the Alibaba Cloud SDK.

      This integration requires calling Wuying Cloud Application OpenAPI operations by using an Alibaba Cloud SDK. We recommend familiarizing yourself with the SDK's usage beforehand. For more information, see Alibaba Cloud SDK.

    • Obtain an AccessKey pair.

      An AccessKey pair consists of an AccessKey ID and an AccessKey secret.

      • AccessKey ID: Identifies the caller, similar to a username.

      • AccessKey secret: Verifies the caller's identity, similar to a password. Keep your AccessKey secret confidential and store it securely.

      Important

      A leaked AccessKey pair for an Alibaba Cloud account exposes all resources under that account. Use a RAM user's AccessKey pair instead of your Alibaba Cloud account's AccessKey pair to limit the impact of a potential leak.

      For instructions, see Create an AccessKey pair.

    • Obtain SDK information.

      Visit the Alibaba Cloud OpenAPI Portal to get information about the Wuying Cloud Application SDK.

      1. Log on to the Alibaba Cloud OpenAPI Portal.

      2. Get SDK installation information.

        Select the Java (async) language tab.

        1. From the product drop-down list at the top, select Wuying Cloud Application.

        2. In the left-side navigation pane, choose SDK > Installation.

        3. Select the correct API version.

          Note

          APIs can belong to different versions, each with its own dependency package. Ensure you import all dependency packages required for the APIs you call.

    • Obtain API information.

      • All OpenAPI operations for Wuying Cloud Application are fully documented. For more information, see API Reference.

      • On an API documentation page, click Debug to open the debugging page for the API.

        Note

        If you are not logged on to the Alibaba Cloud OpenAPI Portal, follow the on-screen instructions to log on.

      • On the API debugging page, you can find the version of the current API in the version drop-down list in the upper-left corner. Click Get SDK to obtain dependency information for that version.

3. How it works

The following diagram shows the key sequence of operations.

image

Key terms:

  • AuthCode: An authorization code issued by the Wuying management service at the request of your backend server. It serves as an identity credential when opening an application. An authorization code can be used only once. You must obtain a new one for each application launch.

  • Wuying Web SDK: Also known as the Wuying Web Client SDK, this is a JavaScript development kit used to connect to cloud computers and cloud applications.

  • StsToken: A restricted identity credential for a convenience account used internally by Wuying. The SDK handles this automatically.

  • Connection ticket: A credential used by the Wuying client-side SDK to establish a connection with the streaming gateway. The SDK handles this automatically.

The process can be divided into four main parts:

  1. Your backend server obtains an authorization code and information about the application to be opened.

  2. Your backend server returns the authorization code and application information to your web frontend (the browser).

  3. Your web frontend passes the authorization code and application information to the Wuying Web SDK. This involves fetching the Wuying Web SDK resource files from a Content Delivery Network (CDN) or your own web server and calling the JavaScript API to pass the parameters.

  4. The Wuying Web SDK starts the cloud application. This includes internal operations such as validating the authorization code and obtaining a connection ticket, which the SDK handles internally.

4. General workflow

The following diagram shows the overall integration workflow.

image

4.1 Log on to the console

  1. Log on to your Alibaba Cloud account.

  2. Log on to the App Streaming console.

4.2 Prepare application resources

  1. Create an image. For more information, see Create and manage images.

  2. Publish an app instance group. For more information, see Publish app instance groups.

4.3 Development and integration

Server-side integration

Your backend server calls Wuying OpenAPI operations to obtain authorization codes, query application information, and release application resources.

  1. Obtain application information, which mainly includes the app ID.

  2. Determine the application launch mode.

    • Authorization mode: Create a convenience account and authorize the app instance group to the convenience account.

    • Non-authorization mode: Configure the app instance group for non-authorization mode by using the SkipUserAuthCheck parameter.

  3. Develop an API endpoint.

    In your service, develop an endpoint to open the application, for example, OpenCloudApp. In this endpoint, call the Alibaba Cloud OpenAPI operation GetAuthCode, and then return the AuthCode, AppId, and AppVersion to the client.

    Note

    Consider an application published in multiple app instance groups. If app instance group A is authorized for convenience account a while all others use non-authorization mode, users with account a are assigned only to group A. The other groups are not considered for scheduling for these users.

Client-side integration

Your client integrates the Wuying Web SDK to launch cloud applications and enable data communication between the client and the cloud. For more information, see the Wuying Web SDK User Guide.

  1. Import the Wuying Web SDK resource files into your frontend project.

  2. Define a method that calls the server-side OpenCloudApp endpoint. Use the AuthCode, AppId, and AppVersion parameters returned by the server to initialize the Wuying Web SDK. After initialization, establish the connection to the cloud application.

  3. Define a button to trigger this method.

After completing these steps, the cloud application screen appears.

5. Feature development examples

5.1 Open an application

Server-side integration

  1. Obtain application information.

    OpenAPI

    Call the ListAppInstanceGroup OpenAPI operation. This operation returns detailed information about app instance groups, including the application information they contain.

    You can directly expose the Wuying application information to your end users, or you can expose your own application information. If you choose the latter, you must maintain a mapping between your application information and Wuying's to ensure the correct parameters are passed to the Wuying Web SDK when a user launches an application.

    Console

    On the console, find the application information within the published app instance group, which mainly includes the AppId.

    On the left-side navigation pane, go to the Apps page. In the application list, the App ID is displayed below each application name in the format app-xxxx. This is the AppId you need.

  2. Determine the application launch mode.

    Authorization mode

    To restrict application access to specific users, use authorization mode. This involves creating a convenience account and authorizing it for the app instance group.

    OpenAPI

    Call the following OpenAPI operations:

    1. Create a convenience account

    2. AuthorizeInstanceGroup.

    Console

    1. Create a convenience account. For more information, see Create a user.

    2. Authorize the app instance group to the convenience account. For more information, see Publish app instance groups.

    Non-authorization mode

    To allow any user to open applications in an app instance group without explicit authorization, configure that group for non-authorization mode.

    Important

    After enabling non-authorization mode, any convenience account under your Alibaba Cloud account can open applications in this app instance group. Be aware of the data security implications.

    Currently, you can configure this mode only by using API operations. You can choose either of the following methods:

    Note

    You can run the API operations directly from the Alibaba Cloud OpenAPI Portal to complete the configuration.

    • When you create the app instance group, set the SkipUserAuthCheck parameter. For more information, see CreateAppInstanceGroup.

    • After creating the app instance group, set the SkipUserAuthCheck parameter by calling the modification API for the group. For more information, see ModifyAppInstanceGroupAttribute.

  3. Obtain an authorization code.

    Call the GetAuthCode OpenAPI operation.

Client-side integration

  1. Initialize the Wuying Web SDK by using the application and identity information returned from your server.

    Wuying.WebSDK.createSession(sid, sessionParam);
    Note

    The parameters in the following table are case-sensitive.

    Parameter

    Type

    Required

    Description

    Identity credential information

    AuthCode

    String

    Yes

    authorization code

    Application information

    AppId

    String

    Yes

    app ID

    AppVersion

    String

    No

    App version. If you do not specify an app version, the service selects a version automatically.

  2. Open the cloud application.

    session.start();

5.2 Release application resources

Wuying Cloud Application provides a session idle policy (session disconnect retention period) on the console that ensures resources are released in a timely manner after use. In addition, Wuying Cloud Application provides the Unbind API to proactively unbind a user from a session. This operation dissociates the user from the session and releases the session resources, giving you more flexible control over the resource lifecycle.

Note

"Unbinding a user from a session" is different from "disconnecting from an application." This feature is not intended for typical disconnection scenarios.

Server-side integration

Call the Unbind OpenAPI operation.

5.3 Server-side binding

Server-side binding allows your backend server to pre-allocate an application instance and start the cloud application by calling a Wuying OpenAPI operation.

image

Server-side integration

Your backend server calls the OpenAPI operations exposed by the Wuying management service to obtain authorization codes, query application information, and release application resources.

  1. Obtain application information.

    OpenAPI

    Call the ListAppInstanceGroup OpenAPI operation. This operation returns detailed information about app instance groups, including the application information they contain.

    You can directly expose the Wuying application information to your end users, or you can expose your own application information. If you choose the latter, you must maintain a mapping between your application information and Wuying's to ensure the correct parameters are passed to the Wuying Web SDK when a user launches an application.

    Console

    On the console, find the application information within the published app instance group, which mainly includes the AppId.

    On the left-side navigation pane, go to the Apps page. In the application list, the App ID is displayed below each application name in the format app-xxxx. This is the AppId you need.

  2. Determine the application launch mode.

    Authorization mode

    To restrict application access to specific users, use authorization mode. This involves creating a convenience account and authorizing it for the app instance group.

    OpenAPI

    Call the following OpenAPI operations:

    1. Create a convenience account

    2. AuthorizeInstanceGroup.

    Console
    1. Create a convenience account. For more information, see Create a user.

    2. Authorize the app instance group to the convenience account. For more information, see Publish app instance groups.

    Non-authorization mode

    To allow any user to open applications in an app instance group without explicit authorization, configure that group for non-authorization mode.

    Important

    After enabling non-authorization mode, any convenience account under your Alibaba Cloud account can open applications in this app instance group. Be aware of the data security implications.

    Currently, you can configure this mode only by using API operations. You can choose either of the following methods:

    Note

    You can run the API operations directly from the Alibaba Cloud OpenAPI Portal to complete the configuration.

    • When you create the app instance group, set the SkipUserAuthCheck parameter. For more information, see CreateAppInstanceGroup.

    • After creating the app instance group, set the SkipUserAuthCheck parameter by calling the modification API for the group. For more information, see ModifyAppInstanceGroupAttribute.

  3. Obtain an authorization code.

    Call the GetAuthCode OpenAPI operation.

  4. Start the application.

    Call the GetConnectionTicket OpenAPI operation.

    Note

    In this scenario, you need to call this API operation only once.

Client-side integration

  1. Initialize the Wuying Web SDK by using the information returned from your server.

    Wuying.WebSDK.createSession(sid, sessionParam);
    Note

    The parameters in the following table are case-sensitive.

    Parameter

    Type

    Required

    Description

    Identity credential information

    AuthCode

    String

    Yes

    authorization code

    Application information

    AppId

    String

    Yes

    app ID

    Startup task information

    TaskId

    String

    Yes

    Task ID

    BizRegionId

    String

    Yes

    The region ID of the task

  2. Open the cloud application.

    session.start();