Methods Summary |
---|
public abstract void | close()Closes the message channel.
|
public java.lang.String | getHost()Gets the host of this message channel.
return this.getSIPStack().getHostAddress();
|
public HostPort | getHostPort()Gets the hostport structure of this message channel.
HostPort retval = new HostPort();
retval.setHost(new Host(this.getHost()));
retval.setPort(this.getPort());
return retval;
|
public static java.lang.String | getKey(java.lang.String inetAddr, int port, java.lang.String transport)Generates a key given the inet address port and transport.
return transport+":"+ inetAddr +":"+port;
|
public abstract java.lang.String | getKey()Generates a key which identifies the message channel.
This allows us to cache the message channel.
|
public MessageProcessor | getMessageProcessor()Gets the message processor.
return this.messageProcessor;
|
public abstract java.lang.String | getPeerAddress()Gets the peer address of the machine that sent us this message.
|
public HostPort | getPeerHostPort()Gets the peer host and port.
HostPort retval = new HostPort();
retval.setHost(new Host(this.getPeerAddress()));
retval.setPort(this.getPeerPort());
return retval;
|
public abstract int | getPeerPort()Gets the sender port (the port of the other end that sent me
the message).
|
public int | getPort()Gets port of this message channel.
if (this.messageProcessor != null)
return messageProcessor.getPort();
else return -1;
|
public abstract SIPMessageStack | getSIPStack()Gets the SIPMessageStack object from this message channel.
|
public abstract java.lang.String | getTransport()Gets transport string of this message channel.
|
public ViaHeader | getViaHeader()Gets the Via header for this transport.
Note that this does not set a branch identifier.
ViaHeader channelViaHeader;
channelViaHeader = new ViaHeader();
channelViaHeader.setTransport(getTransport());
channelViaHeader.setSentBy(getHostPort());
return channelViaHeader;
|
public abstract java.lang.String | getViaHost()Gets the host to assign for an outgoing Request via header.
|
public HostPort | getViaHostPort()Gets the via header host:port structure.
This is extracted from the topmost via header of the request.
HostPort retval = new HostPort();
retval.setHost(new Host(this.getViaHost()));
retval.setPort(this.getViaPort());
return retval;
|
public abstract int | getViaPort()Gets the port to assign for the via header of an outgoing message.
|
public abstract void | handleException(SIPServerException ex)Handles an exception.
|
public abstract boolean | isReliable()Gets whether this channel is reliable or not.
|
public abstract boolean | isSecure()Returns true if this is a secure channel.
|
protected void | logMessage(Message sipMessage, java.lang.String address, int port, long time)Logs a message sent to an address and port via the default interface.
String firstLine = sipMessage.getFirstLine();
CSeqHeader cseq = (CSeqHeader) sipMessage.getCSeqHeader();
CallIdHeader callid = (CallIdHeader) sipMessage.getCallId();
String cseqBody = cseq.encodeBody();
String callidBody = callid.encodeBody();
// Default port.
if (port == -1) port = 5060;
if (ServerLog.needsLogging(ServerLog.TRACE_MESSAGES)) {
Enumeration extList = sipMessage.getHeaders("NISTExtension");
String status = null;
if (extList != null && extList.hasMoreElements()) {
Header exthdr = null;
exthdr = (Header) extList.nextElement();
status = exthdr.getHeaderValue();
}
ServerLog.logMessage(sipMessage.encode(),
this.getHost()+":"+this.getPort(),
address +
":" + port, true, callidBody,
firstLine, status,
sipMessage.getTransactionId(), time);
}
|
public void | logResponse(Response sipResponse, long receptionTime, java.lang.String status)Logs a response received at this message channel.
This is used for processing incoming responses to a client transaction.
try {
int peerport = getPeerPort();
if (peerport == 0 && sipResponse.getContactHeaders() != null) {
ContactHeader contact =
(ContactHeader) sipResponse.getContactHeaders().getFirst();
peerport = ((Address)contact.getAddress()).getPort();
}
String from = getPeerAddress() + ":" + peerport;
String to = this.getHost() + ":" + getPort();
ServerLog.logMessage(sipResponse,
from, to, status, false, receptionTime);
} catch (RuntimeException ex) {
ex.printStackTrace();
}
|
protected abstract void | sendMessage(byte[] message, java.lang.String receiverAddress, int receiverPort)Sends the message (after it has been formatted), to a specified
address and a specified port
|
public void | sendMessage(Message sipMessage, java.lang.String receiverAddress, int receiverPort)Sends a message given SIP message.
long time = System.currentTimeMillis();
byte[] bytes = sipMessage.encodeAsBytes();
sendMessage(bytes, receiverAddress, receiverPort);
logMessage(sipMessage, receiverAddress, receiverPort, time);
|
public abstract void | sendMessage(Message sipMessage)Sends the message (after it has been formatted)
|