Fields Summary |
---|
private com.sun.midp.security.SecurityToken | classSecurityTokenSecurity token for SIP/SIPS protocol class |
private javax.microedition.sip.SipServerConnectionListener | sipServerConnectionListenerListener interface for incoming SIP requests. |
private Vector | messageQueueMessages received held in this vector |
private boolean | connectionOpenflag to know the state of the connection (open or close) |
private String | localHostlisten address |
private int | localPortport number |
private gov.nist.siplite.SipProvider | sipProviderThe Sip Provider for this connection Notifier |
private Thread | listeningThreadAsynchronous notifier thread handle. |
private StackConnector | stackConnectorStack of associtaed connectors. |
private String | mimeTypeType value from
connector.open(...type="application/vnd.company.battleships"...) |
private boolean | waitingForAcceptAndOpenBoolean flag to indicate that this object is in waiting state during
acceptAndOpen() |
boolean | sharedModeIndicates whether this SipConnectionNotifier is opened in shared mode
or not |
Methods Summary |
---|
public javax.microedition.sip.SipServerConnection | acceptAndOpen()Accept and open the client connection.
if (!isConnectionOpen()) {
throw new InterruptedIOException("Connection was closed!");
}
waitingForAcceptAndOpen = true;
// IMPL_NOTE : handle the two others exceptions
// create the sipServerConnection when a request is received
// through the processRequest method the processRequest method
// will add the Request in the Queue and notify()
if (messageQueue == null || messageQueue.size() < 1) {
synchronized (this) {
try {
wait();
} catch (InterruptedException ie) {
if (Logging.REPORT_LEVEL <= Logging.WARNING) {
Logging.report(Logging.WARNING, LogChannels.LC_JSR180,
"SipConnectionNotifierImpl.acceptAndOpen() :" +
"InterruptedException during wait() : " + ie);
ie.printStackTrace();
}
} catch (IllegalMonitorStateException imse) {
if (Logging.REPORT_LEVEL <= Logging.WARNING) {
Logging.report(Logging.WARNING, LogChannels.LC_JSR180,
"SipConnectionNotifierImpl.acceptAndOpen() :" +
"Illgeal monitor state during wait(): " + imse);
imse.printStackTrace();
}
}
}
}
if (!isConnectionOpen()) {
throw new InterruptedIOException("Connection is interrupted!");
}
waitingForAcceptAndOpen = false;
// Get the request received from the message queue
Request request = (Request)messageQueue.firstElement();
// Set up the dialog
SipDialog sipDialog = null;
ServerTransaction serverTransaction =
(ServerTransaction)request.getTransaction();
// Get the nist-siplite dialog
Dialog dialog = serverTransaction.getDialog();
// If the method is an INVITE, SUBSCRIBE or REFER, we create
// a new dialog and add it to the list of dialog we have.
String method = request.getMethod();
if (stackConnector.getSipStack().isDialogCreated(method)) {
// request URI
URI reqURI = null;
ContactList cl = request.getContactHeaders();
if (cl != null) {
if (cl.size() > 0) {
ContactHeader ch = (ContactHeader)cl.getFirst();
Address addr = (Address)ch.getValue();
if (addr != null) {
reqURI = addr.getURI();
}
}
}
if (reqURI == null) {
reqURI = request.getFromHeader().getAddress().getURI();
}
sipDialog = new SipDialogImpl(
dialog,
this,
classSecurityToken);
stackConnector.sipDialogList.addElement(sipDialog);
if (method.equals(Request.INVITE)) {
((SipDialogImpl)sipDialog).setWaitForBye(true);
}
} else if ((dialog != null) &&
(!request.getMethod().equals(Request.CANCEL))) {
sipDialog = stackConnector.findDialog(dialog.getDialogId());
}
// IMPL_NOTE : check security access before returning the connection
SipServerConnection sipServerConnection =
new SipServerConnectionImpl(
request,
sipDialog,
this);
// We remove the request from the queue
messageQueue.removeElementAt(0);
return sipServerConnection;
|
public void | close()Closes the connection notifier handling.
if (!isConnectionOpen()) { // connection is already closed
return;
}
// stop the listening points and sipProvider
if (sharedMode) {
stackConnector.closeSharedSipConnectionNotifier(mimeType);
} else {
SipStack sipStack = sipProvider.getSipStack();
ListeningPoint listeningPoint = sipProvider.getListeningPoint();
try {
sipStack.deleteListeningPoint(listeningPoint);
sipStack.deleteSipProvider(sipProvider);
} catch (ObjectInUseException oiue) {
throw new IOException(oiue.getMessage());
}
/*
* sipStack should be closed only if there are no more
* associated listening points
*/
if (!sipStack.getListeningPoints().hasMoreElements()) {
sipStack.stopStack();
}
}
// Removing the connection from the connection list held by
// the stackConnector
stackConnector.connectionNotifiersList.removeElement(this);
// Notification that the connection has been closed
connectionOpen = false;
if (waitingForAcceptAndOpen) {
synchronized (this) {
try {
notify();
} catch (IllegalMonitorStateException imse) {
if (Logging.REPORT_LEVEL <= Logging.WARNING) {
Logging.report(Logging.WARNING, LogChannels.LC_JSR180,
"SipConnectionNotifierImpl.close() :" +
"Illgeal monitor state during wait(): " + imse);
imse.printStackTrace();
}
}
}
}
// listeningThread = null;
|
public java.lang.String | getLocalAddress()Gets the local IP address for this SIP connection.
if (!isConnectionOpen())
throw new IOException("Connection was closed!");
return localHost;
|
public int | getLocalPort()Gets the local port for this SIP connection.
if (!isConnectionOpen())
throw new IOException("Connection was closed!");
return this.localPort;
|
protected java.lang.String | getMIMEType()Get the MIME type for this SipConnectionNotifier
return mimeType;
|
protected gov.nist.siplite.SipProvider | getSipProvider()Gets the sip provider.
return sipProvider;
|
protected StackConnector | getStackConnector()Gets the current stack connector.
return stackConnector;
|
protected boolean | isConnectionOpen()Gets the connection state.
return connectionOpen;
|
protected void | notifyRequestReceived(gov.nist.siplite.message.Request request)The stack connector notifies this class when it receive a new request
messageQueue.addElement(request);
// We notify the listener that a request has been received
if (this.sipServerConnectionListener != null)
try { // The user code is called
sipServerConnectionListener.notifyRequest(this);
} catch (Throwable exc) { // Ignore any user exception
if (Logging.REPORT_LEVEL <= Logging.WARNING) {
Logging.report(Logging.WARNING, LogChannels.LC_JSR180,
"Exception in notifyRequest() method has been thrown");
}
}
synchronized (this) {
try {
notify();
} catch (IllegalMonitorStateException imse) {
imse.printStackTrace();
}
}
|
public void | setListener(javax.microedition.sip.SipServerConnectionListener sscl)Sets a listener for incoming SIP requests. If a listener is
already set it
will be overwritten. Setting listener to null will remove the current
listener.
if (!isConnectionOpen())
throw new IOException("Connection was closed!");
this.sipServerConnectionListener = sscl;
|