C. When the service connection has been successfully established, the requesting Accessory Peer Agent gets a socket that can be used both to send and receive data to and from Accessory Peer Agents, and to handle service connection-related events.
A. Call the close() method to terminate the service connection with a remote Accessory Peer Agent. When the connection terminates, the onconnectionlost() callback of the SASocketStatusCallback interface is triggered. Similarly, if the remote Accessory Peer Agent terminates the service connection, your application is notified through the same callback, and all established service channels of the service connection are closed by the Accessory Service Framework.
B. Other reasons, such as a network failure or 2 devices becoming out of range while on a wireless connection, can also result in the loss of the service connection. Your service provider and service consumer applications are expected to implement handling mechanisms in the callback for such cases.
The service consumer or service provider can send data to its connected Accessory Peer Agent by simply calling the sendData() method with a socket object. The sendData() method sends the message using the channel ID, which is specified in the Accessory Service Profile and must be declared in the Accessory Service Profile XML file. The message string must not be longer than the value of the maxAllowedDataSize attribute in the SAPeerAgent object.
Set a listener by calling the setDataReceiveListener() method. The listener is called when data is received from a remote Accessory Peer Agent. .
SASocket.setDataReceiveListener(onreceive);
function onreceive(channelId, data)
{
createHTML(data);
}
Manage Your Cookies
We use cookies to improve your experience on our website and to show you relevant
advertising. Manage you settings for our cookies below.
Essential Cookies
These cookies are essential as they enable you to move around the website. This
category cannot be disabled.
Company
Domain
Samsung Electronics
.samsungdeveloperconference.com
Analytical/Performance Cookies
These cookies collect information about how you use our website. for example which
pages you visit most often. All information these cookies collect is used to improve
how the website works.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Functionality Cookies
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and
tailor the website to provide enhanced features and content for you.
Company
Domain
LinkedIn
.ads.linkedin.com, .linkedin.com
Advertising Cookies
These cookies gather information about your browser habits. They remember that
you've visited our website and share this information with other organizations such
as advertisers.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Preferences Submitted
You have successfully updated your cookie preferences.