GDService Class |
Namespace: GD
public sealed class GDService
The GDService type exposes the following members.
Name | Description | |
---|---|---|
Equals | (Inherited from Object.) | |
GetHashCode | (Inherited from Object.) | |
GetType | (Inherited from Object.) | |
SendResponseAsync | Call this function to respond to a consumer application from which a service request has been received in the BlackBerry Inter-Container Communication (ICC) system. The response can include a results map and file attachments to be conveyed to the consumer application. The results will notify the consumer of the success or failure of the request. | |
ToString | (Inherited from Object.) |
Name | Description | |
---|---|---|
HandleRequest | This callback is invoked when a service request is sent to the application within the ICC system. | |
HandleSendingFailed | This event is invoked whenever the delivery of service response via the BlackBerry ICC system fails. | |
HandleSendingFinished | This event is invoked whenever the delivery of a service response via the BlackBerry ICC system completes. | |
HandleSendingPayloadStarted | This callback is invoked whenever transfer of BlackBerry ICC payload file with response to service consumer starts. | |
HandleSendingStarted | This event is invoked whenever transfer of BlackBerry ICC payload file with response to service consumer starts. |
This class is mandatory for service provider applications within the BlackBerry Inter-Container Communication (ICC) system. This class also includes the specific API for sending ICC service responses.
For an overall description of ICC, see under BlackBerry Inter-Container Communication below. To utilize this API the application must meet the requirements listed under Service Provider Requirements.
The functions in this API cannot be used until BlackBerry Dynamics authorization processing is complete, see under GDWindows::Authorize.
BLACKBERRY INTER-CONTAINER COMMUNICATION
The BlackBerry Inter-Container Communication (ICC) system is a means of exchanging data securely between two BlackBerry Dynamics applications running on the same device. The security of data is not compromised during exchange.
Interaction in the ICC system follows a service consumer-provider model. One application initiates communication by sending a service request to another. The initiating application is the service consumer. The application that receives the request is the service provider.
After receiving the service request, the provider executes the necessary processing and could then send a service response back to the consumer. Both the service request and the service response, if any, can contain a number of parameters and file attachments. See under Service Parameters and File Attachments, below.
The sequence of APIs used in a typical ICC interaction is as follows:
Note that an ICC interaction can be initiated with any BlackBerry Dynamics application whose native application identifier is known in the service consumer. The identifier could be known by being present in the application code or, as shown in the above, could be obtained at run time by using BlackBerry Dynamics service discovery. See GDWindows::GetServiceProvidersAsync(GDServiceProviderType, String, String) for details of the service discovery API.
Note that the service provider does not necessarily send a response, i.e. the call to GDService::SendResponseAsync(String, String, IDictionaryString, String, IListIGDStorageFile, GDServiceError) and subsequent invocation of the callback in the consumer do not necessarily take place. The service definition specifies when and whether the provider sends a response, see under Service Definition, below.
The data for requests and responses is sent across an encrypted payload file. The file is created and maintained as necessary by the BlackBerry Dynamics Runtime. This is transparent to the applications, although not always to the end user since the device may sometimes "flip" between applications during ICC interaction. See also the Foreground Execution section, below.
The ICC system cannot be used when running under Enterprise Simulation mode.
By default the ICC system of the SDK for Windows Universal Platform (UWP) can not communicate with ICC system of the SDK for Windows 8.1. See the SDK interoperability related section for instructions on how to enable ICC compatibility mode, here.
SERVICE DEFINITION
The service provided by an application may conform to a declared service definition. The declaration, if there is one, will specify the following:
An application that registers as providing a service for which there is a definition must adhere to the definition. Similarly, an application that consumes a service that is based on a declared definition should only send requests that conform to the definition.
The service definition for a public service may be published to the BlackBerry Dynamics Network (GDN) website. The published definition may include a link to a more detailed API for the service. In any case, the service API may be obtained from the developer of a service provider application, or from the creator of the service definition.
See also: BlackBerry Dynamics Service Definition for a description of BlackBerry Dynamics service definition.
SERVICE PARAMETERS
An ICC service request can include a number of parameters, sent by the consumer. Service responses can also include parameters, sent by the provider to convey detailed results to the consumer. The parameters in a request or response are always provided to the application as a map object. The ICC system supports only string type parameters. Any object serialization must be performed by an application.
Note that the service name, version, and method name are not service parameters as such and are not included in the parameters object.
Error responses can include additional details of the error condition. For example, if a parameter exceeds a maximum value, then the additional details could include the value of the maximum. Additional details are specified in the service definition, per condition, in the same way as service parameters.
FILE ATTACHMENTS
An ICC service request can include a number of file attachments specified by the consumer. Service responses can also include file attachments, when these are sent by the provider as results.
File attachments are sent from the secure store of one application, and copied to the secure store of the other application. Deletion of the recipient's copy of the file is the responsibility of the recipient application. The ICC system does not delete copies of files that were attached to a request or response.
In the API, the sending application specifies file attachments as file handles (GDStorageFile) in its secure store. The ICC system copies the files to the receiving application's secure store, and then invokes a callback in the receiving application. The callback is passed the file handles of the copies, which it can used in the usual manner.
The ICC system uses the following naming convention to construct the paths of the receiving application's copies: Inbox Directory/Sender/Reference time/Original Path where:
Sender | is the native application identifier of the sending application. |
Reference time | is the date and time at which the ICC system started handling the file attachments, down to a millisecond resolution. |
Note that all the files attached to a particular service request or response will be placed under one directory. This means that the receiving application can delete all these files easily, by deleting the directory.
FOREGROUND EXECUTION
Due to Microsoft Windows limitations all ICC service processing in consumer or provider is executed in the foreground. That means that Front Request API/Service isn't available on Windows.
Every time ICC service provider receives a request or ICC service consumer receives a response, the application is switched to foreground execution. This can can cause an impression of "application flickering" if there is frequent request/response interchange. Sending many small requests/responses should be avoided, one large request/response is preferred instead.
SERVICE CONSUMER REQUIREMENTS
To work as an ICC service provider, a BlackBerry Dynamics application must:
Note that an application that provides multiple services still instantiates only a single object of this class. The HandleRequest delegate of the object handles requests for all the services that the application provides.
To be on the list returned by a service discovery query, an application must be registered as a service provider. Register the application as a service provider:
In either user interface, enter the application identifier, for example "com.example.application.name" that is defined in application manifest in Id attribute of Package/Applications/Application tag.
See GDWindows::GetServiceProvidersAsync(GDServiceProviderType, String, String) for details of the service discovery API.