use of javax.sip.SipProvider in project Openfire by igniterealtime.
the class SimpleSession method sendRequest.
/**
* Sends a request with the specified request and transport.
* @param request The request packet.
* @param transport The transport protocol used.
* @param dialog The dialog for a persistent transaction.
* Leave it <code>null</code> if no dialog is associated with this request.
* @throws javax.sip.SipException Unable to communicate.
*/
@SuppressWarnings("unchecked")
private void sendRequest(Request request, String transport, Dialog dialog) throws SipException {
for (Iterator sipProviders = sipStack.getSipProviders(); sipProviders.hasNext(); ) {
SipProvider provider = (SipProvider) sipProviders.next();
if (provider.getListeningPoint(transport) != null) {
Log.debug("Sending packet: \n" + request.toString() + "\n========\n");
ClientTransaction transaction = provider.getNewClientTransaction(request);
if (dialog != null)
dialog.sendRequest(transaction);
else
transaction.sendRequest();
return;
}
}
Log.debug("SimpleSession(" + this.jid.getNode() + "): No SipProvider found for that transport!");
}
use of javax.sip.SipProvider in project camel by apache.
the class SipSubscriptionListener method processNotify.
public synchronized void processNotify(RequestEvent requestEvent, ServerTransaction serverTransactionId) {
LOG.debug("Notification received at Subscriber");
SipProvider provider = (SipProvider) requestEvent.getSource();
Request notify = requestEvent.getRequest();
try {
if (serverTransactionId == null) {
LOG.info("ServerTransaction is null. Creating new Server transaction");
serverTransactionId = provider.getNewServerTransaction(notify);
}
Dialog dialog = serverTransactionId.getDialog();
if (dialog != subscriberDialog) {
forkedDialog = dialog;
}
//Dispatch the response along the route
dispatchExchange(notify.getContent());
// Send back an success response
Response response = sipSubscriber.getConfiguration().getMessageFactory().createResponse(200, notify);
response.addHeader(sipSubscriber.getConfiguration().getContactHeader());
serverTransactionId.sendResponse(response);
SubscriptionStateHeader subscriptionState = (SubscriptionStateHeader) notify.getHeader(SubscriptionStateHeader.NAME);
// Subscription is terminated?
if (subscriptionState.getState().equalsIgnoreCase(SubscriptionStateHeader.TERMINATED)) {
LOG.info("Subscription state is terminated. Deleting the current dialog");
dialog.delete();
}
} catch (Exception e) {
LOG.error("Exception thrown during Notify processing in the SipSubscriptionListener.", e);
}
}
use of javax.sip.SipProvider in project XobotOS by xamarin.
the class SipSessionGroup method reset.
synchronized void reset(String localIp) throws SipException, IOException {
mLocalIp = localIp;
if (localIp == null)
return;
SipProfile myself = mLocalProfile;
SipFactory sipFactory = SipFactory.getInstance();
Properties properties = new Properties();
properties.setProperty("javax.sip.STACK_NAME", getStackName());
properties.setProperty("gov.nist.javax.sip.THREAD_POOL_SIZE", THREAD_POOL_SIZE);
String outboundProxy = myself.getProxyAddress();
if (!TextUtils.isEmpty(outboundProxy)) {
Log.v(TAG, "outboundProxy is " + outboundProxy);
properties.setProperty("javax.sip.OUTBOUND_PROXY", outboundProxy + ":" + myself.getPort() + "/" + myself.getProtocol());
}
SipStack stack = mSipStack = sipFactory.createSipStack(properties);
try {
SipProvider provider = stack.createSipProvider(stack.createListeningPoint(localIp, allocateLocalPort(), myself.getProtocol()));
provider.addSipListener(this);
mSipHelper = new SipHelper(stack, provider);
} catch (InvalidArgumentException e) {
throw new IOException(e.getMessage());
} catch (TooManyListenersException e) {
// must never happen
throw new SipException("SipSessionGroup constructor", e);
}
Log.d(TAG, " start stack for " + myself.getUriString());
stack.start();
mCallReceiverSession = null;
mSessionMap.clear();
resetExternalAddress();
}
use of javax.sip.SipProvider in project jain-sip.ha by RestComm.
the class B2BUAEarlyDialogRecoveryOn2xxTestNotEnabled method stopSipStack.
public static void stopSipStack(SipStack sipStack, SipListener listener) {
Iterator<SipProvider> sipProviderIterator = sipStack.getSipProviders();
try {
while (sipProviderIterator.hasNext()) {
SipProvider sipProvider = sipProviderIterator.next();
ListeningPoint[] listeningPoints = sipProvider.getListeningPoints();
for (ListeningPoint listeningPoint : listeningPoints) {
sipProvider.removeListeningPoint(listeningPoint);
sipStack.deleteListeningPoint(listeningPoint);
listeningPoints = sipProvider.getListeningPoints();
}
sipProvider.removeSipListener(listener);
sipStack.deleteSipProvider(sipProvider);
sipProviderIterator = sipStack.getSipProviders();
}
} catch (Exception e) {
throw new IllegalStateException("Cant remove the listening points or sip providers", e);
}
sipStack.stop();
sipStack = null;
}
use of javax.sip.SipProvider in project jain-sip.ha by RestComm.
the class B2BUAEarlyDialogRecoveryOn1xxTCPTest method stopSipStack.
public static void stopSipStack(SipStack sipStack, SipListener listener) {
Iterator<SipProvider> sipProviderIterator = sipStack.getSipProviders();
try {
while (sipProviderIterator.hasNext()) {
SipProvider sipProvider = sipProviderIterator.next();
ListeningPoint[] listeningPoints = sipProvider.getListeningPoints();
for (ListeningPoint listeningPoint : listeningPoints) {
try {
sipProvider.removeListeningPoint(listeningPoint);
sipStack.deleteListeningPoint(listeningPoint);
} catch (Exception e) {
System.err.println("Cant remove the listening points or sip providers");
}
listeningPoints = sipProvider.getListeningPoints();
}
sipProvider.removeSipListener(listener);
sipStack.deleteSipProvider(sipProvider);
sipProviderIterator = sipStack.getSipProviders();
}
} catch (Exception e) {
throw new IllegalStateException("Cant remove the listening points or sip providers", e);
}
sipStack.stop();
sipStack = null;
}
Aggregations