© 2013 Samsung Electronics Co., Ltd. All rights reserved.
This API allows developers to initiate the AllShare Framework (ASF) which provides convergence services such as media sharing and control sharing.
The ASF is a component which SAMSUNG devices contain to support it as a service.
For more information on the AllShare features, see AllShare Guide.
Interface | Method |
---|---|
WebAPIsAllShareObject | |
AllShare | |
ServiceConnectorObject | |
ServiceProviderCreateSuccessCallback | void onsuccess(ServiceProvider serviceProvider) |
ServiceProviderErrorCallback | void onerror(WebAPIError error, ServiceState state) |
ServiceConnector | void createServiceProvider(ServiceProviderCreateSuccessCallback successCallback, ServiceProviderErrorCallback errorCallback) void deleteServiceProvider(SuccessCallback successCallback, ServiceProviderErrorCallback errorCallback) ServiceProvider? getServiceProvider() |
ServiceProvider | DeviceFinder getDeviceFinder() ServiceState getServiceState() |
Specifies the state of ASF service.
enum ServiceState { "DISABLED", "ENABLED", "UNKNOWN" };
Defines what is instantiated in the webapis object.
[NoInterfaceObject] interface ServiceConnectorObject { readonly attribute ServiceConnector serviceconnector; };
AllShare implements ServiceConnectorObject;
A webapis.allshare.serviceconnector object provides access to the ASF service.
readonly
ServiceConnector serviceconnector
The object provides interfaces for connecting to the ASF service.
Provides a callback when a ServiceProvider object is created successfully.
[Callback=FunctionOnly, NoInterfaceObject] interface ServiceProviderCreateSuccessCallback { void onsuccess(ServiceProvider serviceProvider); };
This callback interface specifies a success callback with ServiceProvider object as an input argument. It is used in an asynchronous operation ServiceConnector.createServiceProvider(...).
onsuccess
Invoked when ServiceProvider is created successfully.
void onsuccess(ServiceProvider serviceProvider);
Provides an error callback when the operation of a ServiceProvider object fails.
[Callback=FunctionOnly, NoInterfaceObject] interface ServiceProviderErrorCallback { void onerror(WebAPIError error, ServiceState state); };
onerror
Invoked when a ServiceProvider operation is failed.
void onerror(WebAPIError error, ServiceState state);
Provides the connection to the AllShare Framework(ASF) service.
[NoInterfaceObject] interface ServiceConnector { void createServiceProvider(ServiceProviderCreateSuccessCallback successCallback, optional ServiceProviderErrorCallback errorCallback); void deleteServiceProvider(SuccessCallback successCallback, optional ServiceProviderErrorCallback errorCallback); ServiceProvider? getServiceProvider(); };
This interface provides interfaces for creating and deleting an ASF service provider.
createServiceProvider
Creates a ServiceProvider object.
void createServiceProvider(ServiceProviderCreateSuccessCallback successCallback, optional ServiceProviderErrorCallback errorCallback);
Asynchronous function that connects application to AllShare framework, and returns ServiceProvider object in success callback.
If this API is invoked several times, an exception with error type AlreadyConnectedError is thrown synchronously.
The error callback is launched with these error types:
with error type UnknownError in any other case.
with error type NotSupportedError, if this feature is not supported.
with error type SecurityError, if this functionality is not allowed.
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type AlreadyConnectedError, if a connection with the allshare service already exists.
// 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
Deletes ServiceProvider object.
void deleteServiceProvider(SuccessCallback successCallback, optional ServiceProviderErrorCallback errorCallback);
Asynchronous function, that disconnects application from AllShare framework
The error callback is launched with these error types:
with error type UnknownError in anyother case.
with error type NotSupportedError, if this feature is not supported.
with error type SecurityError, if this functionality is not allowed.
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
// 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();
Synchronous function, that returns the ServiceProvider object created in the application. If the object is deleted, returns null.
with error type UnknownError in any other case.
with error type NotSupportedError, if this feature is not supported.
with error type SecurityError, if this functionality is not allowed.
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); }
ServiceProvider contains methods allowing you to obtain DeviceFinder object.
[NoInterfaceObject] interface ServiceProvider { DeviceFinder getDeviceFinder(); ServiceState getServiceState(); };
getDeviceFinder
Returns the DeviceFinder object which is used to find allshare devices.
DeviceFinder getDeviceFinder();
with error type UnknownError in any other case.
with error type NotSupportedError, if this feature is not supported.
with error type SecurityError, if this functionality is not allowed.
// 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();
with error type UnknownError in any other case.
with error type NotSupportedError, if this feature is not supported.
with error type SecurityError, if this functionality is not allowed.
module ASFService { enum ServiceState { "DISABLED", "ENABLED", "UNKNOWN" }; [NoInterfaceObject] interface WebAPIsAllShareObject { readonly attribute AllShare allshare; }; WebAPIs implements WebAPIsAllShareObject; [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); void deleteServiceProvider(SuccessCallback successCallback, optional ServiceProviderErrorCallback errorCallback); ServiceProvider? getServiceProvider(); }; [NoInterfaceObject] interface ServiceProvider { DeviceFinder getDeviceFinder(); ServiceState getServiceState(); }; };