-
- All Implemented Interfaces:
-
org.ice4j.ResponseCollector
public class BlockingRequestSender extends AbstractResponseCollector
A utility used to flatten the multi-thread architecture of the Stack and execute the discovery process in a synchronized manner. Roughly what happens here is:
ApplicationThread: sendMessage() wait(); StackThread: processMessage/Timeout() { saveMessage(); notify(); }
-
-
Field Summary
Fields Modifier and Type Field Description private final TransportAddresslocalAddress
-
Constructor Summary
Constructors Constructor Description BlockingRequestSender(StunStack stunStack, TransportAddress localAddress)Creates a new request sender.
-
Method Summary
Modifier and Type Method Description TransportAddressgetLocalAddress()Returns the local Address on which this Blocking Request Sender is bound to. synchronized voidprocessResponse(StunResponseEvent evt)Saves the message event and notifies the discoverer thread so that it may resume. synchronized StunMessageEventsendRequestAndWaitForResponse(Request request, TransportAddress serverAddress)Sends the specified request and blocks until a response has been received or the request transaction has timed out. synchronized StunMessageEventsendRequestAndWaitForResponse(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. -
-
Constructor Detail
-
BlockingRequestSender
BlockingRequestSender(StunStack stunStack, TransportAddress localAddress)
Creates a new request sender.- Parameters:
stunStack- the stack that the sender should send requests through.localAddress- the TransportAddress that requests should be leaving from.
-
-
Method Detail
-
getLocalAddress
TransportAddress getLocalAddress()
Returns the local Address on which this Blocking Request Sender is bound to.
-
processResponse
synchronized void processResponse(StunResponseEvent evt)
Saves the message event and notifies the discoverer thread so that it may resume.
- Parameters:
evt- the newly arrived message event.
-
sendRequestAndWaitForResponse
synchronized 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.
- Parameters:
request- the request to sendserverAddress- the request destination address
-
sendRequestAndWaitForResponse
synchronized 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.
- Parameters:
request- the request to sendserverAddress- the request destination addresstranID- the TransactionID to set for this reuest.
-
-
-
-