public interface IMCServerConnection
extends javax.microedition.io.StreamConnectionNotifier
Connector.open()
with
the server connection URI string according to the BNF syntax defined below.
The attempt to open an IMCServerConnection
more than once with
the same URI, while the previously opened connection is still open, leads
to an exception as for all server connections as defined in GCF. See the
description of Connector.open()
in the GCF specification for
details.
The StreamConnectionNotifier.acceptAndOpen()
method returns an IMCConnection
instance.
In addition to the normal behavior of a StreamConnection
, the
IMCConnection
allows the IMC server to get the requested server
version and the client application's identity. The call to
StreamConnectionNotifier.acceptAndOpen()
is
synchronous and the current thread will be blocked until a client connection
arrives or some exception is thrown. If multiple connection requests arrive
at the same time, the remaining connections will be queued up by the
implementation to be returned by the next acceptAndOpen()
call.
The IMC server connection URIs must conform to the BNF syntax defined below.
If the IMC server connection URI does not conform to this syntax, an
IllegalArgumentException
is thrown.
<server_conn_string> | ::= "imc://" ":" <server name> ":" <server version>";" |
<server name> | ::= IMC server name following the class naming syntax |
<server version> | ::= version of the IMC server. Backward compatibility is assumed.
Versioning follows the
format defined for the MIDlet-Version attribute. |
The IMC server connection URI is used for the connection URL for registering
an application for auto launch (as part of the MIDlet-Push-
attribute). The AllowedSender is either "*" or Application UID. See
IMCConnection
for description of Application UID.
IMC Servers may also be registered dynamically using the
PushRegistry.registerConnection(java.lang.String, java.lang.String, java.lang.String)
API. Here is an example on
registering a IMC Server at installation time:
MIDlet-Push-1:imc://:com.foo.barServer:1.0;, MyIMCServer, * |
An IMC server is assumed to be always backward compatible with earlier
versions. An IMC client can be connected to a server if the version requested
is same or lower than the declared version in the server connection string.
An IMC server can get the requested server version of an established
connection through IMCConnection.getRequestedServerVersion()
method and respond to the client accordingly based on the version requested.
IMCServerConnection serverConn = (IMCServerConnection)Connector.open( "imc://:com.foo.barServer:1.0;"); while(true) { IMCConnection conn = (IMCConnection) serverConn.acceptAndOpen(); try { String requestedVersion = conn.getRequestedServerVersion(); DataInputStream requestData = conn.openDataInputStream(); DataOutputStream responseData = conn.openDataOutputStream(); // read request data from requestData input stream int requestType = requestData.readInt(); ... // Handle the request ... // write response into the output stream responseData.writeUTF("Hello! This is the barServer"); responseData.close(); } finally { conn.close(); } } |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getName()
Get the name of the IMC server
|
java.lang.String |
getVersion()
Get the version of the IMC server
|
Copyright (c) 2014, Oracle and/or its affiliates. All Rights Reserved. Use of this specification is subject to license terms.