Samsung Electronics logo

Samsung Web API: Multiscreen


Introduction

The Samsung Multiscreen API provides new communication mechanism for mobile devices and Samsung TVs utilizing JSON-RPC and multiple transports including HTTP and WebSockets. The JS client implementation makes an extensive use of asynchronous calls and callbacks. Callback handling in both the mobile and TV JS API follows the Samsung "webapi" callback pattern. In this pattern there is a success callback followed by an error callback (the error callback is optional). The success callback will contain the result of the async operation while the error callback will always take a single argument of an error. Please refer to the APIs for method signatures, mandatory and optional arguments, and available class members. For a good starter example of using callbacks within the API please view the "openChannel" example.

The entities in the Samsung Accessory Service are:

  • Application : An Application represents an application on the local or remote device. Use the class to control various aspects of the application such launching the app or getting information
  • Channel : A Channel is a discreet connection where mulitple clients can communicate
  • ChannelClient : A Client of a channel (could be you or another peer connected to the Channel)
  • ChannelClientList : A Client of a channel (could be you or another peer connected to the Channel)
  • Device : The Device class represents a Samsung Connect capable device, traditionally on the remote device, but can be local as well. This class is used to control and retrieve information about the device.

Table of Contents


Summary of Interfaces and Methods

Interface Method
WebAPIsMultiscreenObject
Multiscreen
Device void getCurrent(GetCurrentSuccessCallback successCallback, ErrorCallback? errorCallback)
void getApplication(DOMString runTitle, GetApplicationSuccessCallback successCallback, ErrorCallback? errorCallback)
void getPinCode(GetPinCodeSuccessCallback successCallback, ErrorCallback? errorCallback)
void hidePinCode(HidePinCodeSuccessCallback successCallback, ErrorCallback? errorCallback)
void showPinCode(ShowPinCodeSuccessCallback successCallback, ErrorCallback? errorCallback)
void findByCode(DOMString code, FindByCodeSuccessCallback successCallback, ErrorCallback? errorCallback)
void search(SearchSuccessCallback successCallback, ErrorCallback? errorCallback)
void openChannel(DOMString channelId, Object attributes, OpenChannelSuccessCallback successCallback, ErrorCallback? errorCallback)
void connectToChannel(DOMString channelId, Object attributes, ConnectToChannelSuccessCallback successCallback, ErrorCallback? errorCallback)
Application void install(InstallSuccessCallback successCallback, ErrorCallback? errorCallback)
void launch(Object params, LaunchSuccessCallback successCallback, ErrorCallback? errorCallback)
void terminate(TerminateSuccessCallback successCallback, ErrorCallback? errorCallback)
void updateStatus(UpdateSuccessCallback successCallback, ErrorCallback? errorCallback)
Channel void broadcast(DOMString message, Boolean? encrypt)
void connect(Object attributes, ConnectSuccessCallback successCallback, ErrorCallback? errorCallback)
void disconnect(DisconnectSuccessCallback successCallback, ErrorCallback? errorCallback)
void send(any message, any target, Boolean? encrypt)
void addListener(ChannelEventCallback channelEventCallback)
ChannelClient void send(DOMString message, boolean? encrypt)
ChannelClientList ChannelClient findWhere(Object properties)
void forEach(ForEachCallback iterators, Object context)
ChannelClient get(DOMString id)
ChannelClientArray getAll()
ChannelClient getAt(long index)
void sort(Function compareFunc)
void sortBy(DOMString fieldName, DOMString order)
ChannelClientArray where(Object properties)
GetCurrentSuccessCallback void onsuccess(Device device)
GetApplicationSuccessCallback void onsuccess(Application application)
GetPinCodeSuccessCallback void onsuccess(Object pinCodeInfo)
HidePinCodeSuccessCallback void onsuccess()
ShowPinCodeSuccessCallback void onsuccess()
SearchSuccessCallback void onsuccess(DeviceArray devices)
FindByCodeSuccessCallback void onsuccess(Device device)
OpenChannelSuccessCallback void onsuccess(Channel channel)
ConnectToChannelSuccessCallback void onsuccess(DOMString channel)
InstallSuccessCallback void onsuccess()
LaunchSuccessCallback void onsuccess(DOMString status)
TerminateSuccessCallback void onsuccess(DOMString status)
UpdateSuccessCallback void onsuccess(DOMString status)
ConnectSuccessCallback void onsuccess(ChannelClient client)
DisconnectSuccessCallback void onsuccess()
ForEachCallback void onsuccess(ChannelClient client)
ChannelEventCallback void clientconnected(Client client)
void clientdisconnected(Client client)
void connected()
void disconnected()
void onerror(DOMString error)
void onmessage(DOMString message, Client client)

1. Type Definitions

1.1. ChannelClientArray

Array of ChannelClient

    typedef sequence<ChannelClient> ChannelClientArray;

1.2. DeviceArray

Array of Devices

    typedef sequence<DeviceDevice> DeviceArray;

2. Interfaces

2.1. WebAPIsMultiscreenObject

Defines what is instantiated in the webapis object.

    [NoInterfaceObject] interface WebAPIsMultiscreenObject {
          readonly attribute Multiscreen multiscreen;
    };
    WebAPIs implements WebAPIsMultiscreenObject;

There will be a webapis.chord object that allows accessing the functionality of the Multiscreen API.

2.2. Multiscreen

The Multiscreen root API.

    [NoInterfaceObject] interface Multiscreen {
    };

Multiscreen interfaces will be always available within WebAPIs object in the ECMAScript hierarchy (window.webapis.multiscreen).

2.3. Device

Device

    [NoInterfaceObject] interface Device {

        readonly attribute Object attributes;


        readonly attribute DOMString id;


        readonly attribute DOMString ip;


        readonly attribute DOMString name;


        readonly attribute DOMString networkType;


        readonly attribute DOMString serviceURI;


        readonly attribute DOMString ssid;


        void getCurrent(GetCurrentSuccessCallback successCallback, optional ErrorCallback? errorCallback);



        void getApplication (DOMString runTitle, GetApplicationSuccessCallback successCallback, optional ErrorCallback? errorCallback);



        void getPinCode  (GetPinCodeSuccessCallback successCallback, optional ErrorCallback? errorCallback);



        void hidePinCode  (HidePinCodeSuccessCallback successCallback, optional ErrorCallback? errorCallback);




        void showPinCode  (ShowPinCodeSuccessCallback successCallback, optional ErrorCallback? errorCallback);



        void findByCode(DOMString code, FindByCodeSuccessCallback successCallback, optional ErrorCallback? errorCallback);




        void search (SearchSuccessCallback successCallback, optional ErrorCallback? errorCallback);





        void openChannel  (DOMString channelId, Object attributes, OpenChannelSuccessCallback successCallback, optional ErrorCallback? errorCallback);




        void connectToChannel(DOMString channelId,  Object attributes, ConnectToChannelSuccessCallback successCallback, optional ErrorCallback? errorCallback);
    };

The Device class represents a Samsung Connect capable device, traditionally on the remote device, but can be local as well. This class is used to control and retrieve information about the device.

ATTRIBUTES

readonly Object attributes

The attributes associated with the device

This attribute is read-only.

readonly DOMString id

The unique id of the device

This attribute is read-only.

readonly DOMString ip

The ip address of the device

This attribute is read-only.

readonly DOMString name

The friendly name of the device if known

This attribute is read-only.

readonly DOMString networkType

The network type of of the device if known

This attribute is read-only.

readonly DOMString serviceURI

The multiscreen service endpoint of the device

This attribute is read-only.

readonly DOMString ssid

The ssid of the wireless network the device is connected to Returns null if not connected to wireles

This attribute is read-only.

METHODS

getCurrent

Retrieves the current devices instance

Signature
void getCurrent(GetCurrentSuccessCallback successCallback, optional ErrorCallback? errorCallback);

describe more details

Parameters
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: GetCurrentSuccessCallback.
    • Description: The success callback handler
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: ErrorCallback.
    • Description: The error callback handler
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.This feature is provided from host(DTV) side only

Code example
 function onGetCurrentSuccess(device) {
     console.log("connected to device : " + device.id);
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

getApplication

Retrieves the representation of an application on the device

Signature
void getApplication(DOMString runTitle, GetApplicationSuccessCallback successCallback, optional ErrorCallback? errorCallback);

describe more details

Parameters
  • runTitle
    • Optional: No.
    • Nullable: No.
    • Type: DOMString.
    • Description: The runTitle of the application
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: GetApplicationSuccessCallback.
    • Description: The success callback handler
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: ErrorCallback.
    • Description: The error callback handler
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

    with error type IOError, if an I/O-related error occurs while sending data.

Code example
 function onGetApplicationSuccess(application){
     console.log("application title : " + application.runTitle);
 }

 
 function onGetCurrentSuccess(device) {
     device.getApplication("DemoApp", onGetApplicationSuccess);
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

getPinCode

Retrieves the pin code information associated with cloud discovery

Signature
void getPinCode(GetPinCodeSuccessCallback successCallback, optional ErrorCallback? errorCallback);

describe more details

Parameters
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: GetPinCodeSuccessCallback.
    • Description: The success callback handler
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: ErrorCallback.
    • Description: The error callback handler
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

    with error type IOError, if an I/O-related error occurs while sending data.

Code example
 function onGetPinCodeSuccess(pinCodeInfo){
     console.log("onGetPinCodeSuccess");
 }

 
 function onGetCurrentSuccess(device) {
     device.getPinCode(onGetPinCodeSuccess);
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

hidePinCode

Hides the pin code for the device if it was displayed using the devices system UI

Signature
void hidePinCode(HidePinCodeSuccessCallback successCallback, optional ErrorCallback? errorCallback);

describe more details

Parameters
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: HidePinCodeSuccessCallback.
    • Description: The success callback handler
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: ErrorCallback.
    • Description: The error callback handler
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

Code example
 function onHidePinCodeSuccess(){
     console.log("onHidePinCodeSuccess");
 }

 
 function onGetCurrentSuccess(device) {
     device.hidePinCode(onHidePinCodeSuccess);
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

showPinCode

Displays the current pin code for the device using the devices system UI

Signature
void showPinCode(ShowPinCodeSuccessCallback successCallback, optional ErrorCallback? errorCallback);

describe more details

Parameters
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: ShowPinCodeSuccessCallback.
    • Description: The success callback handler
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: ErrorCallback.
    • Description: The error callback handler
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

Code example
 function onShowPinCodeSuccess(){
     console.log("onShowPinCodeSuccess");
 }

 
 function onGetCurrentSuccess(device) {
     device.showPinCode(onShowPinCodeSuccess);
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

findByCode

Retrieves a device by cloud based pin search

Signature
void findByCode(DOMString code, FindByCodeSuccessCallback successCallback, optional ErrorCallback? errorCallback);

describe more details

Parameters
  • code
    • Optional: No.
    • Nullable: No.
    • Type: DOMString.
    • Description: The code for the device
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: FindByCodeSuccessCallback.
    • Description: The success callback handler
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: ErrorCallback.
    • Description: The error callback handler
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported. This feature is provided from client side only

Code example
 function onFindByCodeSuccess(device) {
     console.log("connected to device : " + device.id);
 }
 
 try {
     var code;  // Let's assume that you have known the code.
     webapis.multiscreen.Device.findByCode(code, onFindByCodeSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

search

Retrieves an array of devices by utilizing cloud based discovery

Signature
void search(SearchSuccessCallback successCallback, optional ErrorCallback? errorCallback);

describe more details

Parameters
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: SearchSuccessCallback.
    • Description: The success callback handler
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: ErrorCallback.
    • Description: The error callback handler
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported. This feature is provided from client side only

Code example
 function onSearchSuccess(devices) {
     var device = devices[0]; // Assuming for this example there is only one
     // We are also assuming in this example your SmartTV application is already running
     // To see how to launch an appliction please refer to device.getApplication and application.launch
     console.log("connected to device : " + device.id);   
 }
 
 try {
     webapis.multiscreen.Device.search(onSearchSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

openChannel

Creates, configures, and connects to a channel

Signature
void openChannel(DOMString channelId, Object attributes, OpenChannelSuccessCallback successCallback, optional ErrorCallback? errorCallback);

describe more details

Parameters
  • channelId
    • Optional: No.
    • Nullable: No.
    • Type: DOMString.
    • Description: The id of the channel (typically the application id)
  • attributes
    • Optional: No.
    • Nullable: No.
    • Type: Object.
    • Description: The attributes to be applied to your client
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: OpenChannelSuccessCallback.
    • Description: The success callback handler
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: ErrorCallback.
    • Description: The error callback handler
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported. This feature is provided from host(DTV) side only

Code example
 function onOpenChannelSuccess(channel){
     console.log("channel opened " + channel.id);
 }
 
 function onGetCurrentSuccess(device) {
     device.openChannel("com.mydomain.myapp.chat",{name:"Host"}, onOpenChannelSuccess);        
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

connectToChannel

Connects to a channel created by the remote application

Signature
void connectToChannel(DOMString channelId, Object attributes, ConnectToChannelSuccessCallback successCallback, optional ErrorCallback? errorCallback);

describe more details

Parameters
  • channelId
    • Optional: No.
    • Nullable: No.
    • Type: DOMString.
    • Description: The id of the channel to connect to
  • attributes
    • Optional: No.
    • Nullable: No.
    • Type: Object.
    • Description: A map of attributes to apply to your client (readable by other clients)
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: ConnectToChannelSuccessCallback.
    • Description: The success callback handler
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: ErrorCallback.
    • Description: The error callback handler
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported. This feature is provided from client side only

    with error type IOError, if an I/O-related error occurs while sending data.

Code example
 function onConnectionSuccess(channel){
     console.log("connected to " + channel.id);
 }
 
 function onSearchSuccess(devices) {
     var device = devices[0]; // Assuming for this example there is only one
     // We are also assuming in this example your SmartTV application is already running
     // To see how to launch an appliction please refer to device.getApplication and application.launch
 
     device.connectToChannel("com.mydomain.myapp.chat",{name:"MobileClient"}, onConnectionSuccess);        
 }
 
 try {
     webapis.multiscreen.Device.search(onSearchSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

2.4. Application

Application

    [NoInterfaceObject] interface Application {

        readonly attribute DOMString STATUS_INSTALLABLE;


        readonly attribute DOMString STATUS_RUNNING;


        readonly attribute DOMString STATUS_STOPPED;


        readonly attribute DOMString lastKnownStatus;


        readonly attribute DOMString runTitle;


        void install (InstallSuccessCallback successCallback, optional ErrorCallback? errorCallback);


        void launch (Object params, LaunchSuccessCallback successCallback, optional ErrorCallback? errorCallback);


        void terminate (TerminateSuccessCallback successCallback, optional ErrorCallback? errorCallback);


        void updateStatus (UpdateSuccessCallback successCallback, optional ErrorCallback? errorCallback);
        
    };

An Application represents an application on the local or remote device. Use the class to control various aspects of the application such launching the app or getting information

ATTRIBUTES

readonly DOMString STATUS_INSTALLABLE

The installable status of the application

This attribute is read-only.

readonly DOMString STATUS_RUNNING

The running status of the application

This attribute is read-only.

readonly DOMString STATUS_STOPPED

The stopped status of the application

This attribute is read-only.

readonly DOMString lastKnownStatus

The last know status of an application. Use updateStatus to refresh the value

This attribute is read-only.

readonly DOMString runTitle

The runTitle of an application.

This attribute is read-only.

METHODS

install

Installs or displays the install UI for the application on the remote device

Signature
void install(InstallSuccessCallback successCallback, optional ErrorCallback? errorCallback);

describe more details

Parameters
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: InstallSuccessCallback.
    • Description: The success callback handler
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: ErrorCallback.
    • Description: The error callback handler
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

Code example
 function onInstallSeccess() {
       console.log("onInstallSeccess");
 }

 function onGetApplicationSuccess(application){
     console.log("application title : " + application.runTitle);
     application.install(onInstallSeccess);
 }

 
 function onGetCurrentSuccess(device) {
     device.getApplication("DemoApp", onGetApplicationSuccess);
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

launch

Launches the application on the remote device

Signature
void launch(Object params, LaunchSuccessCallback successCallback, optional ErrorCallback? errorCallback);

describe more details

Parameters
  • params
    • Optional: No.
    • Nullable: No.
    • Type: Object.
    • Description: A map of parameter to be passed to the application on launch
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: LaunchSuccessCallback.
    • Description: The success callback handler
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: ErrorCallback.
    • Description: The error callback handler
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

    with error type IOError, if an I/O-related error occurs while sending data.

Code example
 function onLauchSuccess(status) {
       console.log("onLauchSuccess status : " + status);
 }

 function onGetApplicationSuccess(application){
     console.log("application title : " + application.runTitle);
     application.launch({launchedBy:"mobile"}, onLauchSuccess);
 }

 
 function onGetCurrentSuccess(device) {
     device.getApplication("DemoApp", onGetApplicationSuccess);
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

terminate

Terminates the application on the remote device

Signature
void terminate(TerminateSuccessCallback successCallback, optional ErrorCallback? errorCallback);

describe more details

Parameters
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: TerminateSuccessCallback.
    • Description: The success callback handler
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: ErrorCallback.
    • Description: The error callback handler
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

    with error type IOError, if an I/O-related error occurs while sending data.

Code example
 function onTerminateSuccess(status) {
       console.log("onTerminateSuccess status : " + status);
 }

 function onGetApplicationSuccess(application){
     console.log("application title : " + application.runTitle);
     application.terminate(onTerminateSuccess);
 }

 
 function onGetCurrentSuccess(device) {
     device.getApplication("DemoApp", onGetApplicationSuccess);
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

updateStatus

Refreshes the lastKnownStatus of the application. Responds with the status.

Signature
void updateStatus(UpdateSuccessCallback successCallback, optional ErrorCallback? errorCallback);

describe more details

Parameters
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: UpdateSuccessCallback.
    • Description: The success callback handler
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: ErrorCallback.
    • Description: The error callback handler
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

    with error type IOError, if an I/O-related error occurs while sending data.

Code example
 function onUpdateStatusSuccess(status) {
       console.log("onUpdateStatusSuccess status : " + status);
 }

 function onGetApplicationSuccess(application){
     console.log("application title : " + application.runTitle);
     application.updateStatus(onUpdateStatusSuccess);
 }

 
 function onGetCurrentSuccess(device) {
     device.getApplication("DemoApp", onGetApplicationSuccess);
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

2.5. Channel

Channel

    [NoInterfaceObject] interface Channel {

        readonly attribute DOMString EVENT_CLIENT_CONNECT;  


        readonly attribute DOMString EVENT_CLIENT_DISCONNECT;


        readonly attribute DOMString EVENT_CONNECT;


        readonly attribute DOMString EVENT_DISCONNECT;


        readonly attribute DOMString EVENT_ERROR;


        readonly attribute DOMString EVENT_MESSAGE;


        readonly attribute ChannelClientList clients; 


        readonly attribute DOMString id;


        readonly attribute boolean isConnected;


        readonly attribute DOMString uri;



        void broadcast (DOMString message, optional ? encrypt);



        void connect (Object attributes, ConnectSuccessCallback successCallback, optional ErrorCallback? errorCallback);



        void disconnect (DisconnectSuccessCallback successCallback, optional ErrorCallback? errorCallback);


        void send (any message, any target, optional ? encrypt);


        void addListener (ChannelEventCallback channelEventCallback);

    };

A Channel is a discreet connection where mulitple clients can communicate

ATTRIBUTES

readonly DOMString EVENT_CLIENT_CONNECT

Constant for the clientConnect event

This attribute is read-only.

readonly DOMString EVENT_CLIENT_DISCONNECT

Constant for the clientDisconnect event

This attribute is read-only.

readonly DOMString EVENT_CONNECT

Constant for the connect event

This attribute is read-only.

readonly DOMString EVENT_DISCONNECT

Constant for the disconnect event

This attribute is read-only.

readonly DOMString EVENT_ERROR

Constant for the error event

This attribute is read-only.

readonly DOMString EVENT_MESSAGE

Constant for the message event

This attribute is read-only.

readonly ChannelClientList clients

A collection of clients currently connected to the channel

This attribute is read-only.

readonly DOMString id

The identifier of the channel

This attribute is read-only.

readonly boolean isConnected

The connection status of the channel

This attribute is read-only.

readonly DOMString uri

The endpoint for connecting to the channel

This attribute is read-only.

METHODS

broadcast

Sends a message to all clients connected to the channel excluding the sender

Signature
void broadcast(DOMString message, optional Boolean? encrypt);

describe more details

Parameters
  • message
    • Optional: No.
    • Nullable: No.
    • Type: DOMString.
    • Description: The message to send
  • encrypt
    • Optional: Yes.
    • Nullable: Yes.
    • Type: Boolean.
    • Description: Should the message be encrypted
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

    with error type IOError, if an I/O-related error occurs while sending data.

Code example
 function onOpenChannelSuccess(channel){
     channel.broadcast("hello", true);
 }
 
 function onGetCurrentSuccess(device) {
     device.openChannel("com.mydomain.myapp.chat",{name:"Host"}, onOpenChannelSuccess);        
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

connect

Connects to the channel

Signature
void connect(Object attributes, ConnectSuccessCallback successCallback, optional ErrorCallback? errorCallback);

describe more details

Parameters
  • attributes
    • Optional: No.
    • Nullable: No.
    • Type: Object.
    • Description: Any attributes you want to associate with the client (ie. {name:"FooBar"})
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: ConnectSuccessCallback.
    • Description: The success callback handler
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: ErrorCallback.
    • Description: The error callback handler
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

    with error type IOError, if an I/O-related error occurs while connecting to channel

Code example
 function onConnectionSuccess(client){
     console.log("connected to the channel");
 }
 
 function onOpenChannelSuccess(channel){
     console.log("connected to channel");
     channel.connect({name:"Host"}, onConnectionSuccess);
 }
 
 function onGetCurrentSuccess(device) {
     device.openChannel("com.mydomain.myapp.chat",{name:"Host"}, onOpenChannelSuccess);        
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

disconnect

Disconnects from the channel

Signature
void disconnect(DisconnectSuccessCallback successCallback, optional ErrorCallback? errorCallback);

describe more details

Parameters
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: DisconnectSuccessCallback.
    • Description: The success callback handler
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: ErrorCallback.
    • Description: The error callback handler
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

    with error type IOError, if an I/O-related error occurs while disconnecting from the channel

Code example
 function onDisconnectionSuccess(){
     console.log("disconnected from channel");
 }
 
 function onOpenChannelSuccess(channel){
     console.log("connected to channel");
     channel.disconnect(onDisconnectionSuccess);
 }
 
 function onGetCurrentSuccess(device) {
     device.openChannel("com.mydomain.myapp.chat",{name:"Host"}, onOpenChannelSuccess);        
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

send

Send message to target (should be modified)

Signature
void send(any message, any target, optional Boolean? encrypt);

Sends a message to the specified target or targets. Targets can be in the for of a clients id, an array of client ids or one of the special message target strings (ie. "all" or "host"}

Parameters
  • message
    • Optional: No.
    • Nullable: No.
    • Type: any.
    • Description: The message to send
  • target
    • Optional: No.
    • Nullable: No.
    • Type: any.
    • Description: The target recipient of the messsage
  • encrypt
    • Optional: Yes.
    • Nullable: Yes.
    • Type: Boolean.
    • Description:
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

    with error type IOError, if an I/O-related error occurs while sending data.

Code example
 function onOpenChannelSuccess(channel){
     channel.send("Hello", "all");
 }
 
 function onGetCurrentSuccess(device) {
     device.openChannel("com.mydomain.myapp.chat",{name:"Host"}, onOpenChannelSuccess);        
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

addListener

Adds a listener to the end of the listeners array for the for the specified event

Signature
void addListener(ChannelEventCallback channelEventCallback);
Parameters
  • channelEventCallback
    • Optional: No.
    • Nullable: No.
    • Type: ChannelEventCallback.
    • Description: Callback that is called channel releated events are fired
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

Code example
 var channelEventCallback = {
       clientconnected : function(client){
           console.log("clientconnected");
       },
       clientdisconnected : function(){
           console.log("clientdisconnected");
       },
       connected : function(){
           console.log("connected");
       },
       disconnected : function(){
           console.log("disconnected");
       },
       onerror : function(error){
           console.log("onerror");
       },
       onmessage : function(message, client) {
           console.log("onmessage");
       }
 }

 function onOpenChannelSuccess(channel){
     channel.addListener(channelEventCallback);
 }
 
 function onGetCurrentSuccess(device) {
     device.openChannel("com.mydomain.myapp.chat",{name:"Host"}, onOpenChannelSuccess);        
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

2.6. ChannelClient

A Client of a channel (could be you or another peer connected to the Channel)

    [NoInterfaceObject] interface ChannelClient {

        readonly attribute Object attributes;


        readonly attribute long connectTime;


        readonly attribute DOMString id;


        readonly attribute boolean isHost;


        readonly attribute boolean isMe;


        void send (DOMString message, optional boolean? encrypt);

    };

ATTRIBUTES

readonly Object attributes

Contains all attributes specified by the client during connection

This attribute is read-only.

readonly long connectTime

Returns the time in milliseconds according to universal time

This attribute is read-only.

readonly DOMString id

The uuid of the client

This attribute is read-only.

readonly boolean isHost

Determines if the client is also the host of the channel

This attribute is read-only.

readonly boolean isMe

Determines if the client is your client

This attribute is read-only.

METHODS

send

Send a message to the client

Signature
void send(DOMString message, optional boolean? encrypt);
Parameters
  • message
    • Optional: No.
    • Nullable: No.
    • Type: DOMString.
    • Description: The message to send
  • encrypt
    • Optional: Yes.
    • Nullable: Yes.
    • Type: boolean.
    • Description: Should the message be encrypted
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

    with error type IOError, if an I/O-related error occurs while sending data.

Code example
 function onOpenChannelSuccess(channel){
     // Assuming for this clientID in known
     var channelClient = channel.clients.get(clientID);
     channelClient.send("hello client", true);
 }
 
 function onGetCurrentSuccess(device) {
     device.openChannel("com.mydomain.myapp.chat",{name:"Host"}, onOpenChannelSuccess); 
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

2.7. ChannelClientList

A Client of a channel (could be you or another peer connected to the Channel)

    [NoInterfaceObject] interface ChannelClientList {

        readonly attribute ChannelClient host;


        readonly attribute long length;


        readonly attribute ChannelClient me;


        ChannelClient findWhere (Object properties);



        void forEach (ForEachCallback iterators, Object context);



        ChannelClient get (DOMString id);


        ChannelClientArray getAll ();


        ChannelClient getAt (long index);


        void sort (Function compareFunc);


        void sortBy (DOMString fieldName, DOMString order);


        ChannelClientArray where (Object properties);
    };

ATTRIBUTES

readonly ChannelClient host

Returns the host client instance

This attribute is read-only.

readonly long length

The length of the collection

This attribute is read-only.

readonly ChannelClient me

Returns the client that represent you

This attribute is read-only.

METHODS

findWhere

Retrieves the first item in the collection matching the properties map (ie. {host:false} )

Signature
ChannelClient findWhere(Object properties);
Parameters
  • properties
    • Optional: No.
    • Nullable: No.
    • Type: Object.
    • Description: The object properties to compare against the item
Return value
ChannelClient
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

Code example
 function onOpenChannelSuccess(channel){
     var channelClient = channel.clients.findWhere({name:"Host"});
     if(channelClient.attributes.name== "Host"){
         console.log("Found it!");
     }
 }
 
 function onGetCurrentSuccess(device) {
     device.openChannel("com.mydomain.myapp.chat",{name:"Host"}, onOpenChannelSuccess);     
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

forEach

Iterates each item in the collection passing the item to the iterator function

Signature
void forEach(ForEachCallback iterators, Object context);
Parameters
  • iterators
    • Optional: No.
    • Nullable: No.
    • Type: ForEachCallback.
    • Description: The iterator function to use
  • context
    • Optional: No.
    • Nullable: No.
    • Type: Object.
    • Description: The context of "this" within the iterator function
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

Code example
 var num = 1;
 
 function onForEachSuccess(channelClient) {
     console.log("channelClient #" + num + " = " channelClient.id);
     num += 1;
 }

 function onOpenChannelSuccess(channel){
     channel.clients.forEach(onForEachSuccess, this);
 }
 
 function onGetCurrentSuccess(device) {
     device.openChannel("com.mydomain.myapp.chat",{name:"Host"}, onOpenChannelSuccess);     
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

get

Returns a client by id

Signature
ChannelClient get(DOMString id);
Parameters
  • id
    • Optional: No.
    • Nullable: No.
    • Type: DOMString.
    • Description: The client uuid
Return value
ChannelClient
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

Code example
 function onOpenChannelSuccess(channel){
     var host = channel.clients.get("host");
 }
 
 function onGetCurrentSuccess(device) {
     device.openChannel("com.mydomain.myapp.chat",{name:"Host"}, onOpenChannelSuccess);     
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

getAll

Retrieves an array of all clients in the collection

Signature
ChannelClientArray getAll();
Return value
ChannelClientArray
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

Code example
 function onOpenChannelSuccess(channel){
     var host = channel.clients.getAll();
     for(i = 0; i  channel.clients.length; i++)
     {
         console.log("#" + i + ": " + host[i].id);
     }
 }
 
 function onGetCurrentSuccess(device) {
     device.openChannel("com.mydomain.myapp.chat",{name:"Host"}, onOpenChannelSuccess);     
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

getAt

Retrieves an item from the collection at a specific index

Signature
ChannelClient getAt(long index);
Parameters
  • index
    • Optional: No.
    • Nullable: No.
    • Type: long.
    • Description: The index of the item to retrieve
Return value
ChannelClient
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

Code example
 function onOpenChannelSuccess(channel){
     var host = channel.clients.getAt(1);
     console.log("#1: " + host.id);
 }
 
 function onGetCurrentSuccess(device) {
     device.openChannel("com.mydomain.myapp.chat",{name:"Host"}, onOpenChannelSuccess);     
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

sort

Sorts a collection using the compare function

Signature
void sort(Function compareFunc);
Parameters
  • compareFunc
    • Optional: No.
    • Nullable: No.
    • Type: Function.
    • Description: The function to to compare items for the sort
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

Code example
 function compareFunc(){
     // your compare function
 }

 function onOpenChannelSuccess(channel){
     channel.clients.sort(compareFunc);
 }
 
 function onGetCurrentSuccess(device) {
     device.openChannel("com.mydomain.myapp.chat",{name:"Host"}, onOpenChannelSuccess);     
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

sortBy

Sorts a collection by a property name in the specified order

Signature
void sortBy(DOMString fieldName, DOMString order);
Parameters
  • fieldName
    • Optional: No.
    • Nullable: No.
    • Type: DOMString.
    • Description: The field name to sort by
  • order
    • Optional: No.
    • Nullable: No.
    • Type: DOMString.
    • Description: The order in which to sort ( "DESC" or "ASC")
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

Code example
 function onOpenChannelSuccess(channel){
     channel.clients.sortBy("id", "ASC");
 }
 
 function onGetCurrentSuccess(device) {
     device.openChannel("com.mydomain.myapp.chat",{name:"Host"}, onOpenChannelSuccess);     
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

where

Retrieves an array of items in the collection matching the properties map (ie. {host:false} )

Signature
ChannelClientArray where(Object properties);
Parameters
  • properties
    • Optional: No.
    • Nullable: No.
    • Type: Object.
    • Description: The object properties to compare against the item
Return value
ChannelClientArray
Exceptions
  • WebAPIException:

    with error type UnknownError In the case of any other error

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

    with error type SecurityError, if this functionality is not allowed.

    with error type NotSupportedError, if this feature is not supported.

Code example
 function onOpenChannelSuccess(channel){
     var host = channel.clients.where({name:"Host"});
     for(i = 0; i  host.length; i++)
     {
         console.log("#" + i + ": " + host[i].id);
     }
 }
 
 function onGetCurrentSuccess(device) {
     device.openChannel("com.mydomain.myapp.chat",{name:"Host"}, onOpenChannelSuccess);     
 }
 
 try {
     webapis.multiscreen.Device.getCurrent(onGetCurrentSuccess);
 } catch(e) {
     console.log("Error exception, error code: " + e.code + ", error message : " + e.message);
 }
 

2.8. GetCurrentSuccessCallback

Callback invoked when current device is retrieved

    [Callback=FunctionOnly, NoInterfaceObject]
    interface GetCurrentSuccessCallback {

        void onsuccess(DeviceDevice device);
    };

METHODS

onsuccess

This callback is invoked when current device is retrieved

Signature
void onsuccess(Device device);
Parameters
  • device
    • Optional: No.
    • Nullable: No.
    • Type: Device.
    • Description: The current device

2.9. GetApplicationSuccessCallback

Callback invoked when the representatino of an application is retrieved

    [Callback=FunctionOnly, NoInterfaceObject]
    interface GetApplicationSuccessCallback {

        void onsuccess(Application application);
    };

METHODS

onsuccess

This callback is invoked when the representatino of an application is retrieved

Signature
void onsuccess(Application application);
Parameters
  • application
    • Optional: No.
    • Nullable: No.
    • Type: Application.
    • Description: The application instance

2.10. GetPinCodeSuccessCallback

Callback invoked when pinCodeInfo object successfully retrieved

    [Callback=FunctionOnly, NoInterfaceObject]
    interface GetPinCodeSuccessCallback {

        void onsuccess(Object pinCodeInfo);
    };

METHODS

onsuccess

Retrieves the pincode information associated with cloud discovery

Signature
void onsuccess(Object pinCodeInfo);
Parameters
  • pinCodeInfo
    • Optional: No.
    • Nullable: No.
    • Type: Object.
    • Description: The pincode information

2.11. HidePinCodeSuccessCallback

Callback invoked when pinCode information is disappeared from the devices UI

    [Callback=FunctionOnly, NoInterfaceObject]
    interface HidePinCodeSuccessCallback {

        void onsuccess();
    };

METHODS

onsuccess

This callback invoked when pinCode information is disappeared from devices UI

Signature
void onsuccess();

2.12. ShowPinCodeSuccessCallback

Callback invoked when pinCode information is displeyed on the devices UI

    [Callback=FunctionOnly, NoInterfaceObject]
    interface ShowPinCodeSuccessCallback {

        void onsuccess();
    };

METHODS

onsuccess

This callback invoked when pinCode information is displeyed on the devices UI

Signature
void onsuccess();

2.13. SearchSuccessCallback

Callback invoked when Device array object successfully retrieved

    [Callback=FunctionOnly, NoInterfaceObject]
    interface SearchSuccessCallback {

        void onsuccess(DeviceArrayDeviceArray devices);
    };

METHODS

onsuccess

This callback is invoked when Device array were successfully retrieved.

Signature
void onsuccess(DeviceArray devices);
Parameters
  • devices
    • Optional: No.
    • Nullable: No.
    • Type: DeviceArray.
    • Description: An array of devices found on your network

2.14. FindByCodeSuccessCallback

Callback invoked when Device object successfully retrieved

    [Callback=FunctionOnly, NoInterfaceObject]
    interface FindByCodeSuccessCallback {

        void onsuccess(DeviceDevice device);
    };

METHODS

onsuccess

This callback is invoked when Device found according to pin code were successfully retrieved.

Signature
void onsuccess(Device device);
Parameters
  • device
    • Optional: No.
    • Nullable: No.
    • Type: Device.
    • Description: A device instance found on your network

2.15. OpenChannelSuccessCallback

Callback invoked when channel is successfully created

    [Callback=FunctionOnly, NoInterfaceObject]
    interface OpenChannelSuccessCallback {

        void onsuccess(Channel channel);
    };

METHODS

onsuccess

This callback invoked when channel is successfully created

Signature
void onsuccess(Channel channel);
Parameters
  • channel
    • Optional: No.
    • Nullable: No.
    • Type: Channel.
    • Description: The created channel

2.16. ConnectToChannelSuccessCallback

Callback invoked when Channel object successfully retrieved

    [Callback=FunctionOnly, NoInterfaceObject]
    interface ConnectToChannelSuccessCallback {

        void onsuccess(DOMString channel);
    };

METHODS

onsuccess

This callback is invoked when Channel which connected were successfully retrieved.

Signature
void onsuccess(DOMString channel);
Parameters
  • channel
    • Optional: No.
    • Nullable: No.
    • Type: DOMString.
    • Description: The connected channel

2.17. InstallSuccessCallback

Callback invoked when ****************************

    [Callback=FunctionOnly, NoInterfaceObject]
    interface InstallSuccessCallback {

        void onsuccess();
    };

METHODS

onsuccess

This callback invoked when ****************************

Signature
void onsuccess();

2.18. LaunchSuccessCallback

Callback invoked when application is launched

    [Callback=FunctionOnly, NoInterfaceObject]
    interface LaunchSuccessCallback {

        void onsuccess(DOMString status);
    };

METHODS

onsuccess

This callback invoked when application is launched

Signature
void onsuccess(DOMString status);
Parameters
  • status
    • Optional: No.
    • Nullable: No.
    • Type: DOMString.
    • Description: The current status of the application

2.19. TerminateSuccessCallback

Callback invoked when application is terminated

    [Callback=FunctionOnly, NoInterfaceObject]
    interface TerminateSuccessCallback {

        void onsuccess(DOMString status);
    };

METHODS

onsuccess

This callback invoked when application is terminated

Signature
void onsuccess(DOMString status);
Parameters
  • status
    • Optional: No.
    • Nullable: No.
    • Type: DOMString.
    • Description: The current status of the application

2.20. UpdateSuccessCallback

Callback invoked when updated application status are retrieved

    [Callback=FunctionOnly, NoInterfaceObject]
    interface UpdateSuccessCallback {

        void onsuccess(DOMString status);
    };

METHODS

onsuccess

This callback invoked when updated application status are retrieved

Signature
void onsuccess(DOMString status);
Parameters
  • status
    • Optional: No.
    • Nullable: No.
    • Type: DOMString.
    • Description: The current status of the application

2.21. ConnectSuccessCallback

Callback invoked when connected to the channel successfully

    [Callback=FunctionOnly, NoInterfaceObject]
    interface ConnectSuccessCallback {

        void onsuccess(ChannelClient client);
    };

METHODS

onsuccess

This callback is invoked when connected to the channel successfully

Signature
void onsuccess(ChannelClient client);
Parameters
  • client
    • Optional: No.
    • Nullable: No.
    • Type: ChannelClient.
    • Description: The channel client representing you

2.22. DisconnectSuccessCallback

Callback invoked when disconnected from channel successfully

    [Callback=FunctionOnly, NoInterfaceObject]
    interface DisconnectSuccessCallback {

        void onsuccess();
    };

METHODS

onsuccess

This callback is invoked when disconnection were successful

Signature
void onsuccess();

2.23. ForEachCallback

Callback invoked to access items from a colletion one at a time

    [Callback=FunctionOnly, NoInterfaceObject]
    interface ForEachCallback {

        void onsuccess(ChannelClient client);
    };

METHODS

onsuccess

Signature
void onsuccess(ChannelClient client);
Parameters
  • client
    • Optional: No.
    • Nullable: No.
    • Type: ChannelClient.
    • Description:

2.24. ChannelEventCallback

Callback invoked when channel releated events are fired

    [Callback, NoInterfaceObject] 
    interface ChannelEventCallback {

        void clientconnected( client);


        void clientdisconnected( client);


        void connected();


        void disconnected();


        void onerror(DOMString error);



        void onmessage(DOMString message,  client);
    };

METHODS

clientconnected

when some client are connected to channel

Signature
void clientconnected(Client client);
Parameters
  • client
    • Optional: No.
    • Nullable: No.
    • Type: Client.
    • Description:

clientdisconnected

invoked when some client are disconnected from channel

Signature
void clientdisconnected(Client client);
Parameters
  • client
    • Optional: No.
    • Nullable: No.
    • Type: Client.
    • Description:

connected

invoked when connected to channel

Signature
void connected();

disconnected

invoked when disconnected from channel

Signature
void disconnected();

onerror

invoked when some error are happened

Signature
void onerror(DOMString error);
Parameters
  • error
    • Optional: No.
    • Nullable: No.
    • Type: DOMString.
    • Description:

onmessage

invoked when some message are retrived

Signature
void onmessage(DOMString message, Client client);
Parameters
  • message
    • Optional: No.
    • Nullable: No.
    • Type: DOMString.
    • Description: received message
  • client
    • Optional: No.
    • Nullable: No.
    • Type: Client.
    • Description: message sender

3. Full WebIDL

module Multiscreen {



    typedef sequence<ChannelClient> ChannelClientArray;


    typedef sequence<DeviceDevice> DeviceArray;


    [NoInterfaceObject] interface WebAPIsMultiscreenObject {
          readonly attribute Multiscreen multiscreen;
    };
    WebAPIs implements WebAPIsMultiscreenObject;
    

    [NoInterfaceObject] interface Multiscreen {
    };


    

    [NoInterfaceObject] interface Device {

        readonly attribute Object attributes;


        readonly attribute DOMString id;


        readonly attribute DOMString ip;


        readonly attribute DOMString name;


        readonly attribute DOMString networkType;


        readonly attribute DOMString serviceURI;


        readonly attribute DOMString ssid;


        void getCurrent(GetCurrentSuccessCallback successCallback, optional ErrorCallback? errorCallback);



        void getApplication (DOMString runTitle, GetApplicationSuccessCallback successCallback, optional ErrorCallback? errorCallback);



        void getPinCode  (GetPinCodeSuccessCallback successCallback, optional ErrorCallback? errorCallback);



        void hidePinCode  (HidePinCodeSuccessCallback successCallback, optional ErrorCallback? errorCallback);




        void showPinCode  (ShowPinCodeSuccessCallback successCallback, optional ErrorCallback? errorCallback);



        void findByCode(DOMString code, FindByCodeSuccessCallback successCallback, optional ErrorCallback? errorCallback);




        void search (SearchSuccessCallback successCallback, optional ErrorCallback? errorCallback);





        void openChannel  (DOMString channelId, Object attributes, OpenChannelSuccessCallback successCallback, optional ErrorCallback? errorCallback);




        void connectToChannel(DOMString channelId,  Object attributes, ConnectToChannelSuccessCallback successCallback, optional ErrorCallback? errorCallback);
    };

    

    [NoInterfaceObject] interface Application {

        readonly attribute DOMString STATUS_INSTALLABLE;


        readonly attribute DOMString STATUS_RUNNING;


        readonly attribute DOMString STATUS_STOPPED;


        readonly attribute DOMString lastKnownStatus;


        readonly attribute DOMString runTitle;


        void install (InstallSuccessCallback successCallback, optional ErrorCallback? errorCallback);


        void launch (Object params, LaunchSuccessCallback successCallback, optional ErrorCallback? errorCallback);


        void terminate (TerminateSuccessCallback successCallback, optional ErrorCallback? errorCallback);


        void updateStatus (UpdateSuccessCallback successCallback, optional ErrorCallback? errorCallback);
        
    };


    [NoInterfaceObject] interface Channel {

        readonly attribute DOMString EVENT_CLIENT_CONNECT;  


        readonly attribute DOMString EVENT_CLIENT_DISCONNECT;


        readonly attribute DOMString EVENT_CONNECT;


        readonly attribute DOMString EVENT_DISCONNECT;


        readonly attribute DOMString EVENT_ERROR;


        readonly attribute DOMString EVENT_MESSAGE;


        readonly attribute ChannelClientList clients; 


        readonly attribute DOMString id;


        readonly attribute boolean isConnected;


        readonly attribute DOMString uri;



        void broadcast (DOMString message, optional ? encrypt);



        void connect (Object attributes, ConnectSuccessCallback successCallback, optional ErrorCallback? errorCallback);



        void disconnect (DisconnectSuccessCallback successCallback, optional ErrorCallback? errorCallback);


        void send (any message, any target, optional ? encrypt);


        void addListener (ChannelEventCallback channelEventCallback);

    };


    [NoInterfaceObject] interface ChannelClient {

        readonly attribute Object attributes;


        readonly attribute long connectTime;


        readonly attribute DOMString id;


        readonly attribute boolean isHost;


        readonly attribute boolean isMe;


        void send (DOMString message, optional boolean? encrypt);

    };


    [NoInterfaceObject] interface ChannelClientList {

        readonly attribute ChannelClient host;


        readonly attribute long length;


        readonly attribute ChannelClient me;


        ChannelClient findWhere (Object properties);



        void forEach (ForEachCallback iterators, Object context);



        ChannelClient get (DOMString id);


        ChannelClientArray getAll ();


        ChannelClient getAt (long index);


        void sort (Function compareFunc);


        void sortBy (DOMString fieldName, DOMString order);


        ChannelClientArray where (Object properties);
    };


    [Callback=FunctionOnly, NoInterfaceObject]
    interface GetCurrentSuccessCallback {

        void onsuccess(DeviceDevice device);
    };



    [Callback=FunctionOnly, NoInterfaceObject]
    interface GetApplicationSuccessCallback {

        void onsuccess(Application application);
    };




    [Callback=FunctionOnly, NoInterfaceObject]
    interface GetPinCodeSuccessCallback {

        void onsuccess(Object pinCodeInfo);
    };



    [Callback=FunctionOnly, NoInterfaceObject]
    interface HidePinCodeSuccessCallback {

        void onsuccess();
    };



    [Callback=FunctionOnly, NoInterfaceObject]
    interface ShowPinCodeSuccessCallback {

        void onsuccess();
    };



    [Callback=FunctionOnly, NoInterfaceObject]
    interface SearchSuccessCallback {

        void onsuccess(DeviceArrayDeviceArray devices);
    };




    [Callback=FunctionOnly, NoInterfaceObject]
    interface FindByCodeSuccessCallback {

        void onsuccess(DeviceDevice device);
    };




    [Callback=FunctionOnly, NoInterfaceObject]
    interface OpenChannelSuccessCallback {

        void onsuccess(Channel channel);
    };



    [Callback=FunctionOnly, NoInterfaceObject]
    interface ConnectToChannelSuccessCallback {

        void onsuccess(DOMString channel);
    };




    [Callback=FunctionOnly, NoInterfaceObject]
    interface InstallSuccessCallback {

        void onsuccess();
    };




    [Callback=FunctionOnly, NoInterfaceObject]
    interface LaunchSuccessCallback {

        void onsuccess(DOMString status);
    };




    [Callback=FunctionOnly, NoInterfaceObject]
    interface TerminateSuccessCallback {

        void onsuccess(DOMString status);
    };



    [Callback=FunctionOnly, NoInterfaceObject]
    interface UpdateSuccessCallback {

        void onsuccess(DOMString status);
    };



    [Callback=FunctionOnly, NoInterfaceObject]
    interface ConnectSuccessCallback {

        void onsuccess(ChannelClient client);
    };



    [Callback=FunctionOnly, NoInterfaceObject]
    interface DisconnectSuccessCallback {

        void onsuccess();
    };


    [Callback=FunctionOnly, NoInterfaceObject]
    interface ForEachCallback {

        void onsuccess(ChannelClient client);
    };    


    [Callback, NoInterfaceObject] 
    interface ChannelEventCallback {

        void clientconnected( client);


        void clientdisconnected( client);


        void connected();


        void disconnected();


        void onerror(DOMString error);



        void onmessage(DOMString message,  client);
    };
};