top

ASFService API

To use Samsung Product API, 

<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>

Should be loaded in index.html

 

This  allows developers to initiate the AllShare Framework

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

Table of Contents

  1. 1. Type Definitions
    1. 1.1. ServiceState
  2. 2. Interfaces
    1. 2.1. WebApiAllShareObject
    2. 2.2. AllShare
    3. 2.3. ServiceConnectorObject
    4. 2.4. ServiceProviderCreateSuccessCallback
    5. 2.5. ServiceProviderErrorCallback
    6. 2.6. ServiceConnector
    7. 2.7. ServiceProvider
  3. 3. Full WebIDL

Summary of Interfaces and Methods

Interface Method
WebApiAllShareObject  
AllShare  
ServiceConnectorObject  
ServiceProviderCreateSuccessCallback void onsuccess (ServiceProvider serviceProvider)
ServiceProviderErrorCallback void onerror (WebAPIError error, ServiceState state)
ServiceConnector void createServiceProvider (ServiceProviderCreateSuccessCallback successCallback, optional ServiceProviderErrorCallback errorCallback)
void deleteServiceProvider (SuccessCallback successCallback, optional ServiceProviderErrorCallback errorCallback)
ServiceProvider? getServiceProvider ()
ServiceProvider DeviceFinder getDeviceFinder ()
ServiceState getServiceState ()

1. Type Definitions

1.1. ServiceState

Specifies the state of ASF service.

  enum ServiceState {
      "DISABLED",
      "ENABLED",
      "UNKNOWN"
  };

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

The following values are supported

  • DISABLED - The service state is "disabled
  • ENABLED - The service state is "enabled"
  • UNKNOWN - The service state is unknown

2. Interfaces

2.1. WebApiAllShareObject

Defines what is instantiated in the AllShareObject

  [NoInterfaceObject] interface WebApiAllShareObject {
      readonly attribute AllShare allshare;
  };

  WebApi implements WebApiAllShareObject;

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

Attributes

  • readonly AllShare allshare
    The object will provide interfaces for connecting services and obtaining AllShare devices.

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

2.2. AllShare

The AllShare root API

  [NoInterfaceObject] interface AllShare {
  };

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

2.3. ServiceConnectorObject

Defines what is instantiated in the webapis object.

  [NoInterfaceObject] interface ServiceConnectorObject {
      readonly attribute ServiceConnector serviceconnector;   
  };

  AllShare implements ServiceConnectorObject;

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

Attributes

  • readonly ServiceConnector serviceconnector
    The object provides interfaces for connecting to the ASF service.

    Since : 1.0

    Privilege level: public

    Privilege: http://developer.samsung.com/privilege/allshare

2.4. ServiceProviderCreateSuccessCallback

a callback when a ServiceProvider object is created successfully.

  [Callback=FunctionOnly, NoInterfaceObject] interface ServiceProviderCreateSuccessCallback {
      void onsuccess(ServiceProvider serviceProvider);
  };   

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

Methods

onsuccess
Invoked when ServiceProvider is created successfully.

  void onsuccess(ServiceProvider serviceProvider);

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

Parameters:

  • serviceProvider: the ServiceConnector object which is successfully created

2.5. ServiceProviderErrorCallback

Provides an error callback when the operation of a ServiceProvider object fails.

  [Callback=FunctionOnly, NoInterfaceObject] interface ServiceProviderErrorCallback {
      void onerror(WebAPIError error,
                   ServiceState state);
  };

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

Methods

onerror
Invoked when a ServiceProvider operation is failed.

  void onerror(WebAPIError error,
               ServiceState state);

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

Parameters:

  • error: object which indicates error type and message.
  • state: Current state of the Service.

2.6. ServiceConnector

Provides the connection to the AllShare Framework(ASF) service.

  [NoInterfaceObject] interface ServiceConnector {
      void createServiceProvider(ServiceProviderCreateSuccessCallback successCallback,
                                 optional ServiceProviderErrorCallback errorCallback) raises(WebAPIException);
      void deleteServiceProvider(SuccessCallback successCallback,
                                 optional ServiceProviderErrorCallback errorCallback) raises(WebAPIException);
      ServiceProvider? getServiceProvider() raises(WebAPIException);
  };

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

Methods

createServiceProvider
Creates a ServiceProvider object.

  void createServiceProvider(ServiceProviderCreateSuccessCallback successCallback,
                             optional ServiceProviderErrorCallback errorCallback) raises(WebAPIException);

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

Parameters:

  • successCallback: callback function called if the request is successful
  • errorCallback [optional]: callback function called if the request if fails

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if the input parameter is not compatible with the expected type.

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

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value.

    • with error type UnknownError in any other error case.

Code example:


  // Define success callback for creating ServiceProvider
  function sProviderCallback(provider) {          
      console.log("The service provider has obtained");
  }         

  // Define error callback for creating ServiceProvider
  function eProviderCallback(error, state) {         
      console.log(error.name);
      console.log("Current ASF service state: " + state);         
  }        

  // Try to create ServiceProvider object.
  try {
      webapis.allshare.serviceconnector.createServiceProvider(sProviderCallback, eProviderCallback);
  }
  catch(e) {
      console.log(e.message);
  }
deleteServiceProvider
Delete ServiceProvider object.

  void deleteServiceProvider(SuccessCallback successCallback,
                             optional ServiceProviderErrorCallback errorCallback) raises(WebAPIException);

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

Parameters:

  • successCallback: Callback function called if the request is successful
  • errorCallback [optional]: Callback function called if the request is fails

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if the input parameter is not compatible with the expected type.

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

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value.

    • with error type UnknownError in any other error case.

Code example:


  // ServiceProvider object - it is assumed that you have created serviceProvider.
  var serviceProvider;         

  // Define a success callback for deleting ServiceProvider
  function sProviderDeleteCallback() {          
      console.log("The ASF service provider has been deleted properly.");
  }          
  
  // Define an error callback for creating ServiceProvider
  function eProviderDeleteCallback(error, state) {         
      console.log(error.name);
      console.log("The current ASF service state: " + state);         
  }        
  
  // Try to delete ServiceProvider object.
  try {
      webapis.allshare.serviceconnector.deleteServiceProvider(sProviderDeleteCallback, eProviderDeleteCallback);
  }
  catch(e) {
      console.log(e.message);
  }
getServiceProvider
Returns a ServiceProvider object that is connected to AllShare framework

  ServiceProvider? getServiceProvider() raises(WebAPIException);

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

Return value:

ServiceProvider ServiceProvider object that is connected to AllShare framework

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if the input parameter is not compatible with the expected type.

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

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value.

    • with error type UnknownError in any other error case.

Code example:


  try {
      // it is assumed that createServiceProvider() is successfully invoked
      var serviceProvider = webapis.allshare.serviceconnector.getServiceProvider();
      if (serviceProvider == null) {
          console.log("Service provider had not been created properly");
      }
  }
  catch(e) {
      console.log(e.message);
  }             

2.7. ServiceProvider

ServiceProvider contains methods allowing you to obtain DeviceFinder object.

  [NoInterfaceObject] interface ServiceProvider {
      DeviceFinder getDeviceFinder() raises(WebAPIException);
      ServiceState getServiceState() raises(WebAPIException);        
  };

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

Methods

getDeviceFinder
Returns the DeviceFinder object which is used to find allshare devices.

  DeviceFinder getDeviceFinder() raises(WebAPIException); 

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

Return value:

DeviceFinder DeviceFinder object

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if the input parameter is not compatible with the expected type.

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

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value.

    • with error type UnknownError in any other error case.

Code example:


  // It is assumed that the ServiceProvider object is successfully obtained. For further details, see the createServiceProvider() or getServiceProvider().
  var serviceProvider;           

  try {
      deviceFinder = serviceProvider.getDeviceFinder();
  } catch(e) {
      console.log(e.name);
  }
getServiceState
Provides the current state of the ASF service

  ServiceState getServiceState() raises(WebAPIException);         

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/allshare

Return value:

ServiceState ServiceState value

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if the input parameter is not compatible with the expected type.

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

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value.

    • with error type UnknownError in any other error case.

Code example:


  // It is assumed that the ServiceProvider object is successfully obtained.
  var serviceProvider;           

  try {
      serviceState = serviceProvider.getServiceState();
  } catch(e) {
      console.log(e.name);
  }

3. Full WebIDL


  module ASFService {
      enum ServiceState {
          "DISABLED",
          "ENABLED",
          "UNKNOWN"
      };

      [NoInterfaceObject] interface WebApiAllShareObject {
          readonly attribute AllShare allshare;
      };
      WebApi implements WebApiAllShareObject;    

      [NoInterfaceObject] interface AllShare {
      };

      [NoInterfaceObject] interface ServiceConnectorObject {
          readonly attribute ServiceConnector serviceconnector;   
      };
      AllShare implements ServiceConnectorObject;

      [Callback=FunctionOnly, NoInterfaceObject] interface ServiceProviderCreateSuccessCallback {
          void onsuccess(ServiceProvider serviceProvider);
      };    

      [Callback=FunctionOnly, NoInterfaceObject] interface ServiceProviderErrorCallback {
          void onerror(WebAPIError error,
                       ServiceState state);
      };

      [NoInterfaceObject] interface ServiceConnector {
          void createServiceProvider(ServiceProviderCreateSuccessCallback successCallback,
                                     optional ServiceProviderErrorCallback errorCallback) raises(WebAPIException);
          void deleteServiceProvider(SuccessCallback successCallback,
                                     optional ServiceProviderErrorCallback errorCallback) raises(WebAPIException);
          ServiceProvider? getServiceProvider() raises(WebAPIException);
      };

      [NoInterfaceObject] interface ServiceProvider {
          DeviceFinder getDeviceFinder() raises(WebAPIException);
          ServiceState getServiceState() raises(WebAPIException);        
      };
  };