Fields Summary |
---|
protected static com.sun.midp.security.SecurityToken | internalSecurityTokenInternal security token that grants access to restricted API. |
private static final int | EMUL_PORTKeeps default port number for server connections. |
private static String | serverIPIP address of EmulationServer. |
protected Messenger | messengerKeeps messenger that proveds utilities for communicating with server. |
protected javax.microedition.io.SocketConnection | connectionKeeps socket connection to the server. |
protected InputStream | fromServerKeeps input stream from server. |
protected OutputStream | toServerKeeps output stream to server. |
Methods Summary |
---|
protected void | connect()Opens socket connection to current host at current port.
if (connection != null) {
throw new IOException("connection is already open");
}
connection = (SocketConnection)
new com.sun.midp.io.j2me.socket.Protocol().openPrim(
internalSecurityToken,
"//" + getServer() + ":" + EMUL_PORT);
fromServer = connection.openDataInputStream();
toServer = connection.openDataOutputStream();
|
protected void | disconnect()Closes current socket connection.
if (connection != null) {
messenger.send(toServer, Messenger.DONE, "");
toServer.close();
fromServer.close();
connection.close();
toServer = null;
fromServer = null;
connection = null;
}
|
static native java.lang.String | getLocalIP()Retrieves local IP address.
|
private static synchronized java.lang.String | getServer()Retrieves emulation server IP address, launches server if needed.
if (serverIP != null) {
return serverIP;
}
serverIP = getServerIP();
// Local IP of emulation server means that it is possibly
// expected that current application will launch the server.
if (serverIP == null || serverIP.length() == 0
|| serverIP.equals("127.0.0.1")) {
EmulationServer.launch();
serverIP = "localhost";
} else if (serverIP.equals(getLocalIP())) {
EmulationServer.launch();
}
return serverIP;
|
private static native java.lang.String | getServerIP()Retrieves port of emulation server.
|