Search in sources :

Example 1 with MessageProcessor

use of gov.nist.javax.sip.stack.MessageProcessor in project XobotOS by xamarin.

the class SipStackImpl method createListeningPoint.

/*
	 * (non-Javadoc)
	 * 
	 * @see javax.sip.SipStack#createListeningPoint(java.lang.String, int,
	 * java.lang.String)
	 */
public synchronized ListeningPoint createListeningPoint(String address, int port, String transport) throws TransportNotSupportedException, InvalidArgumentException {
    if (isLoggingEnabled())
        getStackLogger().logDebug("createListeningPoint : address = " + address + " port = " + port + " transport = " + transport);
    if (address == null)
        throw new NullPointerException("Address for listening point is null!");
    if (transport == null)
        throw new NullPointerException("null transport");
    if (port <= 0)
        throw new InvalidArgumentException("bad port");
    if (!transport.equalsIgnoreCase("UDP") && !transport.equalsIgnoreCase("TLS") && !transport.equalsIgnoreCase("TCP") && !transport.equalsIgnoreCase("SCTP"))
        throw new TransportNotSupportedException("bad transport " + transport);
    /** Reusing an old stack instance */
    if (!this.isAlive()) {
        this.toExit = false;
        this.reInitialize();
    }
    String key = ListeningPointImpl.makeKey(address, port, transport);
    ListeningPointImpl lip = (ListeningPointImpl) listeningPoints.get(key);
    if (lip != null) {
        return lip;
    } else {
        try {
            InetAddress inetAddr = InetAddress.getByName(address);
            MessageProcessor messageProcessor = this.createMessageProcessor(inetAddr, port, transport);
            if (this.isLoggingEnabled()) {
                this.getStackLogger().logDebug("Created Message Processor: " + address + " port = " + port + " transport = " + transport);
            }
            lip = new ListeningPointImpl(this, port, transport);
            lip.messageProcessor = messageProcessor;
            messageProcessor.setListeningPoint(lip);
            this.listeningPoints.put(key, lip);
            // start processing messages.
            messageProcessor.start();
            return (ListeningPoint) lip;
        } catch (java.io.IOException ex) {
            if (isLoggingEnabled())
                getStackLogger().logError("Invalid argument address = " + address + " port = " + port + " transport = " + transport);
            throw new InvalidArgumentException(ex.getMessage(), ex);
        }
    }
}
Also used : TransportNotSupportedException(javax.sip.TransportNotSupportedException) InvalidArgumentException(javax.sip.InvalidArgumentException) MessageProcessor(gov.nist.javax.sip.stack.MessageProcessor) ListeningPoint(javax.sip.ListeningPoint) IOException(java.io.IOException) InetAddress(java.net.InetAddress)

Aggregations

MessageProcessor (gov.nist.javax.sip.stack.MessageProcessor)1 IOException (java.io.IOException)1 InetAddress (java.net.InetAddress)1 InvalidArgumentException (javax.sip.InvalidArgumentException)1 ListeningPoint (javax.sip.ListeningPoint)1 TransportNotSupportedException (javax.sip.TransportNotSupportedException)1