class Connector extends Object implements Runnable
messageConsumer
as well as sending
datagrams to the STUN server specified by the
original NetAccessPointDescriptor.Modifier and Type | Field and Description |
---|---|
private ErrorHandler |
errorHandler
The instance to be notified if errors occur in the network listening
thread.
|
private TransportAddress |
listenAddress
The address that we are listening to.
|
private static Logger |
logger
Our class logger.
|
private Consumer<RawMessage> |
messageConsumer
The consumer of incoming RawMessages
|
private TransportAddress |
remoteAddress
The remote address of the socket of this Connector if it is
a TCP socket, or null if it is UDP.
|
private boolean |
running
A flag that is set to false to exit the message processor.
|
private IceSocketWrapper |
sock
The socket object that used by this access point to access the network.
|
private Object |
sockLock
The object that we use to lock socket operations (since the socket itself
is often null)
|
Modifier | Constructor and Description |
---|---|
protected |
Connector(IceSocketWrapper socket,
TransportAddress remoteAddress,
Consumer<RawMessage> messageConsumer,
ErrorHandler errorHandler)
Creates a network access point.
|
Modifier and Type | Method and Description |
---|---|
(package private) TransportAddress |
getListenAddress()
Returns the TransportAddress that this access point is bound
on.
|
(package private) TransportAddress |
getRemoteAddress()
Returns the remote TransportAddress or null if none
is specified.
|
protected IceSocketWrapper |
getSocket()
Returns the DatagramSocket that contains the port and address
associated with this access point.
|
void |
run()
The listening thread's run method.
|
(package private) void |
sendMessage(byte[] message,
TransportAddress address)
Sends message through this access point's socket.
|
(package private) void |
start()
Start the network listening thread.
|
protected void |
stop()
Makes the access point stop listening on its socket.
|
String |
toString()
Returns a String representation of the object.
|
private static final Logger logger
private final Consumer<RawMessage> messageConsumer
private IceSocketWrapper sock
private final Object sockLock
private boolean running
private final ErrorHandler errorHandler
private final TransportAddress listenAddress
private final TransportAddress remoteAddress
protected Connector(IceSocketWrapper socket, TransportAddress remoteAddress, Consumer<RawMessage> messageConsumer, ErrorHandler errorHandler)
socket
- the socket that this access point is supposed to use for
communication.remoteAddress
- the remote address of the socket of this
Connector
if it is a TCP socket, or null if it is UDP.messageConsumer
- the incoming messages consumererrorHandler
- the instance to notify when errors occur.void start()
protected IceSocketWrapper getSocket()
protected void stop()
void sendMessage(byte[] message, TransportAddress address) throws IOException
message
- the bytes to send.address
- message destination.IOException
- if an exception occurs while sending the message.public String toString()
TransportAddress getListenAddress()
TransportAddress getRemoteAddress()
Copyright © 2018. All rights reserved.