public class UDPMessageChannel extends MessageChannel implements ParseExceptionListener, Runnable, RawMessageChannel
Modifier and Type | Field and Description |
---|---|
protected MessageParser |
myParser
The parser we are using for messages received from this channel.
|
protected int |
myPort |
protected SIPTransactionStack |
sipStack
SIP Stack structure for this channel.
|
messageProcessor, useCount
Modifier | Constructor and Description |
---|---|
protected |
UDPMessageChannel(InetAddress targetAddr,
int port,
SIPTransactionStack sipStack,
UDPMessageProcessor messageProcessor)
Constructor.
|
protected |
UDPMessageChannel(SIPTransactionStack stack,
UDPMessageProcessor messageProcessor,
DatagramPacket packet)
Constructor.
|
protected |
UDPMessageChannel(SIPTransactionStack stack,
UDPMessageProcessor messageProcessor,
String threadName)
Constructor - takes a datagram packet and a stack structure Extracts the
address of the other from the datagram packet and stashes away the
pointer to the passed stack structure.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the message channel.
|
boolean |
equals(Object other)
Compare two UDP Message channels for equality.
|
String |
getHost()
get the stack address for the stack that received this message.
|
String |
getKey()
Generate a key which identifies the message channel.
|
String |
getPeerAddress()
get the address of the host that sent me the message
|
protected InetAddress |
getPeerInetAddress() |
String |
getPeerName()
get the name (address) of the host that sent me the message
|
InetAddress |
getPeerPacketSourceAddress() |
int |
getPeerPacketSourcePort() |
int |
getPeerPort()
Get the sender port ( the port of the other end that sent me the message).
|
String |
getPeerProtocol() |
int |
getPort()
get the port.
|
SIPTransactionStack |
getSIPStack()
get the stack pointer.
|
String |
getTransport()
Return a transport string.
|
String |
getViaHost()
Get the logical originator of the message (from the top via header).
|
int |
getViaPort()
Get the logical port of the message orginator (from the top via hdr).
|
void |
handleException(ParseException ex,
SIPMessage sipMessage,
Class hdrClass,
String header,
String message)
Implementation of the ParseExceptionListener interface.
|
boolean |
isReliable()
Returns "false" as this is an unreliable transport.
|
boolean |
isSecure()
UDP is not a secure protocol.
|
void |
processMessage(SIPMessage sipMessage)
Actually proces the parsed message.
|
void |
run()
Run method specified by runnnable.
|
protected void |
sendMessage(byte[] msg,
InetAddress peerAddress,
int peerPort,
boolean reConnect)
Send a message to a specified receiver address.
|
protected void |
sendMessage(byte[] msg,
InetAddress peerAddress,
int peerPort,
String peerProtocol,
boolean retry)
Send a message to a specified receiver address.
|
void |
sendMessage(SIPMessage sipMessage)
Return a reply from a pre-constructed reply.
|
createBadReqRes, getEncapsulatedClientTransaction, getHostPort, getKey, getKey, getMessageProcessor, getPeerHostPort, getRawIpSourceAddress, getViaHeader, getViaHostPort, logMessage, logResponse, sendMessage, sendMessage, setEncapsulatedClientTransaction, uncache
protected SIPTransactionStack sipStack
protected MessageParser myParser
protected int myPort
protected UDPMessageChannel(SIPTransactionStack stack, UDPMessageProcessor messageProcessor, String threadName)
stack
- is the shared SIPStack structuremessageProcessor
- is the creating message processor.threadName
- name that will be affected to the underlying threadprotected UDPMessageChannel(SIPTransactionStack stack, UDPMessageProcessor messageProcessor, DatagramPacket packet)
stack
- is the SIP sipStack.messageProcessor
- is the creating message processor.packet
- is the incoming datagram packet.protected UDPMessageChannel(InetAddress targetAddr, int port, SIPTransactionStack sipStack, UDPMessageProcessor messageProcessor)
targetAddr
- INET address of the place where we want to send messages.port
- target port (where we want to send the message).sipStack
- our SIP Stack.public void processMessage(SIPMessage sipMessage)
processMessage
in interface RawMessageChannel
sipMessage
- public void handleException(ParseException ex, SIPMessage sipMessage, Class hdrClass, String header, String message) throws ParseException
handleException
in interface ParseExceptionListener
ex
- Exception that is given to us by the parser.sipMessage
- -- sip message being processed.header
- -- header/RL/SL text being parsed.message
- -- message where this header was detected.ParseException
- If we choose to reject the header or message.public void sendMessage(SIPMessage sipMessage) throws IOException
sendMessage
in class MessageChannel
sipMessage
- Message string to send.IOException
- If there is a problem with sending the message.protected void sendMessage(byte[] msg, InetAddress peerAddress, int peerPort, boolean reConnect) throws IOException
sendMessage
in class MessageChannel
msg
- string to send.peerAddress
- Address of the place to send it to.peerPort
- the port to send it to.IOException
- If there is trouble sending this message.protected void sendMessage(byte[] msg, InetAddress peerAddress, int peerPort, String peerProtocol, boolean retry) throws IOException
msg
- message string to send.peerAddress
- Address of the place to send it to.peerPort
- the port to send it to.peerProtocol
- protocol to use to send.IOException
- If there is trouble sending this message.public SIPTransactionStack getSIPStack()
getSIPStack
in class MessageChannel
public String getTransport()
getTransport
in class MessageChannel
public String getHost()
getHost
in class MessageChannel
public int getPort()
getPort
in class MessageChannel
public String getPeerName()
public String getPeerAddress()
getPeerAddress
in class MessageChannel
protected InetAddress getPeerInetAddress()
getPeerInetAddress
in class MessageChannel
public boolean equals(Object other)
public String getKey()
MessageChannel
getKey
in class MessageChannel
public int getPeerPacketSourcePort()
getPeerPacketSourcePort
in class MessageChannel
public InetAddress getPeerPacketSourceAddress()
getPeerPacketSourceAddress
in class MessageChannel
public String getViaHost()
getViaHost
in class MessageChannel
public int getViaPort()
getViaPort
in class MessageChannel
public boolean isReliable()
isReliable
in class MessageChannel
public boolean isSecure()
isSecure
in class MessageChannel
public int getPeerPort()
MessageChannel
getPeerPort
in class MessageChannel
public String getPeerProtocol()
getPeerProtocol
in class MessageChannel
public void close()
close
in class MessageChannel
Copyright © 2015. All Rights Reserved.