Search in sources :

Example 11 with Host

use of gov.nist.core.Host in project XobotOS by xamarin.

the class MessageProcessor method getViaHeader.

/**
     * Get the Via header to assign for this message processor. The topmost via
     * header of the outoging messages use this.
     *
     * @return the ViaHeader to be used by the messages sent via this message processor.
     */
public Via getViaHeader() {
    try {
        Via via = new Via();
        if (this.sentByHostPort != null) {
            via.setSentBy(sentByHostPort);
            via.setTransport(this.getTransport());
        } else {
            Host host = new Host();
            host.setHostname(this.getIpAddress().getHostAddress());
            via.setHost(host);
            via.setPort(this.getPort());
            via.setTransport(this.getTransport());
        }
        return via;
    } catch (ParseException ex) {
        ex.printStackTrace();
        return null;
    } catch (InvalidArgumentException ex) {
        ex.printStackTrace();
        return null;
    }
}
Also used : InvalidArgumentException(javax.sip.InvalidArgumentException) Host(gov.nist.core.Host) ParseException(java.text.ParseException) Via(gov.nist.javax.sip.header.Via)

Example 12 with Host

use of gov.nist.core.Host in project XobotOS by xamarin.

the class SIPTransactionStack method createMessageChannel.

/**
     * Creates a client transaction to handle a new request. Gets the real message channel from
     * the superclass, and then creates a new client transaction wrapped around this channel.
     *
     * @param nextHop Hop to create a channel to contact.
     */
public MessageChannel createMessageChannel(SIPRequest request, MessageProcessor mp, Hop nextHop) throws IOException {
    // New client transaction to return
    SIPTransaction returnChannel;
    // Create a new client transaction around the
    // superclass' message channel
    // Create the host/port of the target hop
    Host targetHost = new Host();
    targetHost.setHostname(nextHop.getHost());
    HostPort targetHostPort = new HostPort();
    targetHostPort.setHost(targetHost);
    targetHostPort.setPort(nextHop.getPort());
    MessageChannel mc = mp.createMessageChannel(targetHostPort);
    // available for the transport.
    if (mc == null)
        return null;
    returnChannel = createClientTransaction(request, mc);
    ((SIPClientTransaction) returnChannel).setViaPort(nextHop.getPort());
    ((SIPClientTransaction) returnChannel).setViaHost(nextHop.getHost());
    addTransactionHash(returnChannel);
    // returnChannel.startTransactionTimer();
    return returnChannel;
}
Also used : HostPort(gov.nist.core.HostPort) Host(gov.nist.core.Host)

Aggregations

Host (gov.nist.core.Host)12 HostPort (gov.nist.core.HostPort)9 ParseException (java.text.ParseException)3 InvalidArgumentException (javax.sip.InvalidArgumentException)2 NameValue (gov.nist.core.NameValue)1 Via (gov.nist.javax.sip.header.Via)1 SIPRequest (gov.nist.javax.sip.message.SIPRequest)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 Iterator (java.util.Iterator)1