public class NIOHandler extends Object
Modifier | Constructor and Description |
---|---|
protected |
NIOHandler(SIPTransactionStack sipStack,
NioTcpMessageProcessor messageProcessor) |
Modifier and Type | Method and Description |
---|---|
void |
closeAll()
Close all the cached connections.
|
SocketChannel |
createOrReuseSocket(InetAddress inetAddress,
int port) |
protected SocketChannel |
getSocket(String key) |
protected static String |
makeKey(InetAddress addr,
int port) |
protected static String |
makeKey(String addr,
int port) |
protected void |
putSocket(String key,
SocketChannel sock)
Thread safety delivered through keyedSemaphore.
|
protected void |
removeSocket(SocketChannel channel)
Searches matching socket in internal map, and then removes from internal
structures.
|
SocketChannel |
sendBytes(InetAddress senderAddress,
InetAddress receiverAddress,
int contactPort,
String transport,
byte[] bytes,
boolean retry,
NioTcpMessageChannel messageChannel)
Send an array of bytes.
|
void |
stop() |
protected NIOHandler(SIPTransactionStack sipStack, NioTcpMessageProcessor messageProcessor)
protected static String makeKey(InetAddress addr, int port)
protected void putSocket(String key, SocketChannel sock)
key
- sock
- protected SocketChannel getSocket(String key)
protected void removeSocket(SocketChannel channel)
channel
- public SocketChannel sendBytes(InetAddress senderAddress, InetAddress receiverAddress, int contactPort, String transport, byte[] bytes, boolean retry, NioTcpMessageChannel messageChannel) throws IOException
receiverAddress
- -- inet addresscontactPort
- -- port to connect to.transport
- -- tcp or udp.retry
- -- retry to connect if the other end closed connectionIOException
- -- if there is an IO exception sending message.public void closeAll()
public void stop()
public SocketChannel createOrReuseSocket(InetAddress inetAddress, int port) throws IOException
IOException
Copyright © 2016. All Rights Reserved.