Methods Summary |
---|
public void | commandAction(Command command, Displayable screen)Callback for user interface interactions.
if (command == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
|
public void | destroyApp(boolean unconditional)Destroys the MIDlet and cleans up all opened
resources.
for (int i = 0; i < connections.length; i++) {
if (scn[i] != null) {
try {
scn[i].close();
} catch (Exception ex) {
}
}
}
|
public void | notifyRequest(SipConnectionNotifier scn)Callback listener for inbound messages.
try {
SipServerConnection ssc;
// retrieve the request received
ssc = scn.acceptAndOpen();
// Check for NOTIFY message
if (ssc.getMethod().equals("NOTIFY")) {
updateScreen(ssc.getMethod());
} else {
updateScreen(ssc.getMethod());
}
} catch (Exception ex) {
// handle Exceptions
ex.printStackTrace();
updateScreen(ex.getMessage());
}
|
public void | pauseApp()Pauses the MIDlet.
|
public void | startApp()Launches the MIDlet.
// Attempt dynamic registration with port
try {
PushRegistry
.registerConnection("sip:5081",
"examples.SipPushTest",
"*");
} catch (Exception ex) {
ex.printStackTrace();
updateScreen(ex.getMessage());
}
try {
PushRegistry
.unregisterConnection("sip:5081");
} catch (Exception ex) {
ex.printStackTrace();
updateScreen(ex.getMessage());
}
// Attempt dynamic registration with port and transport
try {
PushRegistry
.registerConnection("sip:5081;transport=udp",
"examples.SipPushTest",
"*");
} catch (Exception ex) {
ex.printStackTrace();
updateScreen(ex.getMessage());
}
try {
PushRegistry
.unregisterConnection("sip:5081;transport=udp");
} catch (Exception ex) {
ex.printStackTrace();
updateScreen(ex.getMessage());
}
// Verify dynamic registration with port and transport=tcp
// is blocked.
try {
PushRegistry
.registerConnection("sip:5081;transport=tcp",
"examples.SipPushTest",
"*");
} catch (Exception ex) {
// Should fail - "transport=tcp" not supported
}
// Verify dynamic registration for sips is blocked
try {
PushRegistry
.registerConnection("sips:5081",
"examples.SipPushTest",
"*");
} catch (Exception ex) {
// Should fail - "sips" not supported
}
// Check the list of pending connections
connections = PushRegistry.listConnections(false);
if (connections != null &&
connections.length > 0) {
scn = new SipConnectionNotifier[connections.length];
for (int i = 0; i < connections.length; i++) {
// Open connection for the designated push registration
try {
scn[i] = (SipConnectionNotifier)
Connector.open(connections[i]);
// Register callback method
scn[i].setListener(this);
} catch (Exception ex) {
// handle Exceptions
ex.printStackTrace();
updateScreen(ex.getMessage());
}
}
}
|
public void | updateScreen(java.lang.String s)Constructs a messgae array and quit button and
displays message to end user.
exitCommand = new Command("Exit", Command.EXIT, 1);
textBox = new TextBox("SipPushTest", s, s.length(),
TextField.ANY | TextField.UNEDITABLE);
textBox.addCommand(exitCommand);
textBox.setCommandListener(this);
display = Display.getDisplay(this);
display.setCurrent(textBox);
|