April 12, 2007, 2:32 a.m.
posted by barateon
Handling Connections after LaunchThe MIDlet is responsible for handling incoming connections once it has been started. When a MIDlet associated with a push connection starts, it should first check why it was started. That is, it should get the list of available connections with input available. (See Section 17.2.3, "Mechanics of Dynamic Push Registration," for information on the listConnections method.) If there are such connections, the MIDlet can assume it was started to handle them. The AMS holds onto the incoming connections until the MIDlet opens them. (This is known as handing off the connections to the MIDlet.) The MIDlet opens a connection by passing a connection string returned by the listConnections method directly to the Connector.open method. To prevent data loss, a MIDlet is responsible for all I/O operations on the connection from the time it calls the Connector.open method until it closes the connection. Application developers should avoid closing the connection too early. If the connection is closed but the MIDlet is still running, neither the AMS nor the application will be listening for push notifications. Inbound data could be lost if the application closes the connection before all data has been received. Application developers should also use a separate thread to perform input and output (I/O) operations and avoid blocking (and possibly deadlocking against) interactive user operations. A push application should behave in a predictable manner when handling asynchronous data it obtains through the push mechanism. A well-behaved application should inform the user that data has been processed. While it is possible to write applications that do not use any user visible interfaces, launching an application that only performs a background function could be a confusing user experience. |
- Comment