public class BlockingRequestSender extends AbstractResponseCollector
ApplicationThread:
sendMessage()
wait();
StackThread:
processMessage/Timeout()
{
saveMessage();
notify();
}
Modifier and Type | Field and Description |
---|---|
private boolean |
ended
Determines whether this request sender has completed its course.
|
private TransportAddress |
localAddress
The transport address that we are bound on.
|
private static Logger |
logger
Our class logger
|
private StunMessageEvent |
responseEvent
The StunMessageEvent that contains the response matching our
request.
|
private Object |
sendLock
A lock object that we are using to synchronize sending.
|
private StunStack |
stunStack
The stack that we are using to send requests through.
|
Constructor and Description |
---|
BlockingRequestSender(StunStack stunStack,
TransportAddress localAddress)
Creates a new request sender.
|
Modifier and Type | Method and Description |
---|---|
TransportAddress |
getLocalAddress()
Returns the local Address on which this Blocking Request Sender is bound
to.
|
protected void |
processFailure(BaseStunMessageEvent event)
Notifies this ResponseCollector that a transaction described by
the specified BaseStunMessageEvent has failed.
|
void |
processResponse(StunResponseEvent evt)
Saves the message event and notifies the discoverer thread so that
it may resume.
|
StunMessageEvent |
sendRequestAndWaitForResponse(Request request,
TransportAddress serverAddress)
Sends the specified request and blocks until a response has been
received or the request transaction has timed out.
|
StunMessageEvent |
sendRequestAndWaitForResponse(Request request,
TransportAddress serverAddress,
TransactionID tranID)
Sends the specified request and blocks until a response has been
received or the request transaction has timed out with given
transactionID.
|
processTimeout, processUnreachable
private static final Logger logger
private final StunStack stunStack
private final TransportAddress localAddress
private StunMessageEvent responseEvent
private boolean ended
private final Object sendLock
public BlockingRequestSender(StunStack stunStack, TransportAddress localAddress)
stunStack
- the stack that the sender should send requests
through.localAddress
- the TransportAddress that requests should be
leaving from.public TransportAddress getLocalAddress()
protected void processFailure(BaseStunMessageEvent event)
processFailure
in class AbstractResponseCollector
event
- the BaseStunMessageEvent which describes the failed
transaction and the runtime type of which specifies the failure reasonAbstractResponseCollector.processFailure(BaseStunMessageEvent)
public void processResponse(StunResponseEvent evt)
evt
- the newly arrived message event.public StunMessageEvent sendRequestAndWaitForResponse(Request request, TransportAddress serverAddress) throws StunException, IOException
request
- the request to sendserverAddress
- the request destination addressIOException
- if an error occurs while sending message bytes
through the network socket.IllegalArgumentException
- if the apDescriptor references an
access point that had not been installed,StunException
- if message encoding fails,public StunMessageEvent sendRequestAndWaitForResponse(Request request, TransportAddress serverAddress, TransactionID tranID) throws StunException, IOException
request
- the request to sendserverAddress
- the request destination addresstranID
- the TransactionID to set for this reuest.IOException
- if an error occurs while sending message bytes
through the network socket.IllegalArgumentException
- if the apDescriptor references an
access point that had not been installed,StunException
- if message encoding fails,Copyright © 2018. All rights reserved.