SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.netaddr
Class BlockingRequestSender

java.lang.Object
  extended by net.java.sip.communicator.impl.netaddr.BlockingRequestSender
All Implemented Interfaces:
net.java.stun4j.ResponseCollector

 class BlockingRequestSender
extends Object
implements net.java.stun4j.ResponseCollector

A utility used to flatten the multithreaded 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(); }

Organisation:

Louis Pasteur University, Strasbourg, France

Network Research Team (http://www-r2.u-strasbg.fr)

Version:
0.1
Author:
Emil Ivov

Field Summary
(package private)  net.java.stun4j.StunMessageEvent responseEvent
           
 
Constructor Summary
BlockingRequestSender(net.java.stun4j.stack.StunProvider stunProvider, net.java.stun4j.NetAccessPointDescriptor apDescriptor)
           
 
Method Summary
 void processResponse(net.java.stun4j.StunMessageEvent evt)
          Saves the message event and notifies the discoverer thread so that it may resume.
 void processTimeout()
          Notifies the discoverer thread when a message has timeouted so that it may resume and consider it as unanswered.
 net.java.stun4j.StunMessageEvent sendRequestAndWaitForResponse(net.java.stun4j.message.Request request, net.java.stun4j.StunAddress serverAddress)
          Sends the specified request and blocks until a response has been received or the request transaction has timed out.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

responseEvent

net.java.stun4j.StunMessageEvent responseEvent
Constructor Detail

BlockingRequestSender

BlockingRequestSender(net.java.stun4j.stack.StunProvider stunProvider,
                      net.java.stun4j.NetAccessPointDescriptor apDescriptor)
Method Detail

processResponse

public void processResponse(net.java.stun4j.StunMessageEvent evt)
Saves the message event and notifies the discoverer thread so that it may resume.

Specified by:
processResponse in interface net.java.stun4j.ResponseCollector
Parameters:
evt - the newly arrived message event.

processTimeout

public void processTimeout()
Notifies the discoverer thread when a message has timeouted so that it may resume and consider it as unanswered.

Specified by:
processTimeout in interface net.java.stun4j.ResponseCollector

sendRequestAndWaitForResponse

public net.java.stun4j.StunMessageEvent sendRequestAndWaitForResponse(net.java.stun4j.message.Request request,
                                                                      net.java.stun4j.StunAddress serverAddress)
                                                               throws net.java.stun4j.StunException,
                                                                      IOException,
                                                                      IllegalArgumentException
Sends the specified request and blocks until a response has been received or the request transaction has timed out.

Parameters:
request - the reuqest to send
serverAddress - the request destination address
Returns:
the event encapsulating the response or null if no response has been received.
Throws:
net.java.stun4j.StunException - NETWORK_ERROR or other if we fail to send the message
IOException
IllegalArgumentException

SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.