|
MIDP3.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IMCServerConnection
This interface defines a server connection for the Inter-MIDlet Communication (IMC) protocol. A server connection is obtained through Connector.open() with the server connection URI string according to the BNF syntax defined below.
The 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
MIDlet's identity. The call to IMCServerConnection.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.
In the connection URI string, the IMC server can specify authorization requirements for the IMC clients. If authorization is required (by specifying authmode=true in the connection URI), only the connection requests from access authorized MIDlets will be accepted. See Application Level Access Authorization for more details. If authmode=false is specified or if this does not appear in the connection URI, the server connection will accept connection from any client that meets the name and version requirements.
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> ";" [<authmode>] |
<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. |
<authmode> | ::= authmode=true|false |
The IMC server connection URI is used for the connection URL for registering a MIDlet
for auto launch (as part of the MIDlet-Push-<n>
attribute). The AllowedSender
is either "*" or MIDlet_UID. See IMCConnection
for description of MIDlet_UID.
IMC Servers may also be registered dynamically using the PushRegistry.registerConnection()
API. Here is an example on registering a IMC Server at installation time,
MIDlet-Push-1:imc://:com.foo.barServer:1.0;authmode=true, 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;authmode=true); 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(); } }
Method Summary | |
---|---|
java.lang.String |
getName()
Get the name of the IMC server |
java.lang.String |
getVersion()
Get the version of the IMC server |
Methods inherited from interface javax.microedition.io.StreamConnectionNotifier |
---|
acceptAndOpen |
Methods inherited from interface javax.microedition.io.Connection |
---|
close |
Method Detail |
---|
java.lang.String getName()
java.lang.String getVersion()
|
MIDP3.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |