Implements server side role conflict detection and resolution (RFC 5245: Section 7.2.1.1)
This commit is contained in:
parent
cc51f9ff21
commit
91b3474a79
@ -19,7 +19,7 @@ public interface ResponseCollector
|
||||
*
|
||||
* @param response the response to dispatch.
|
||||
*/
|
||||
public void processResponse(StunMessageEvent response);
|
||||
public void processResponse(StunResponseEvent response);
|
||||
|
||||
/**
|
||||
* Notifies this collector that no response had been received after repeated
|
||||
|
||||
@ -161,8 +161,34 @@ public class ConnectivityCheckClient
|
||||
}
|
||||
}
|
||||
|
||||
public void processResponse(StunMessageEvent response)
|
||||
public void processResponse(StunResponseEvent response)
|
||||
{
|
||||
if(response.getResponse().getMessageType()
|
||||
== Response.BINDING_ERROR_RESPONSE)
|
||||
{
|
||||
if(! response.getResponse().contains(Attribute.ERROR_CODE))
|
||||
return; //malformed error response
|
||||
|
||||
processErrorResponse(response);
|
||||
}
|
||||
}
|
||||
|
||||
private void processErrorResponse(StunResponseEvent evt)
|
||||
{
|
||||
Response response = evt.getResponse();
|
||||
Request originalRequest = evt.getRequest();
|
||||
|
||||
Attribute errorCode = response.getAttribute(Attribute.ERROR_CODE);
|
||||
|
||||
//RESOLVE ROLE_CONFLICTS
|
||||
if(response.contains(ErrorCodeAttribute.ROLE_CONFLICT))
|
||||
{
|
||||
boolean wasControlling = originalRequest
|
||||
.contains(Attribute.ICE_CONTROLLING);
|
||||
|
||||
logger.finest("Swithing to isControlling=" + !wasControlling);
|
||||
parentAgent.setControlling(!wasControlling);
|
||||
}
|
||||
}
|
||||
|
||||
public void processTimeout(StunTimeoutEvent event)
|
||||
|
||||
@ -309,7 +309,7 @@ public class StunCandidateHarvester
|
||||
*
|
||||
* @param response the response that we've just received from a StunServer.
|
||||
*/
|
||||
public void processResponse(StunMessageEvent response)
|
||||
public void processResponse(StunResponseEvent response)
|
||||
{
|
||||
synchronized (resolveMap)
|
||||
{
|
||||
|
||||
@ -357,7 +357,8 @@ class StunClientTransaction
|
||||
if( keepTran == null || !keepTran.trim().equalsIgnoreCase("true"))
|
||||
this.cancel();
|
||||
|
||||
this.responseCollector.processResponse(evt);
|
||||
this.responseCollector.processResponse(new StunResponseEvent(
|
||||
evt.getRawMessage(), (Response)evt.getMessage(), this.request));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -106,7 +106,7 @@ class BlockingRequestSender
|
||||
* it may resume.
|
||||
* @param evt the newly arrived message event.
|
||||
*/
|
||||
public synchronized void processResponse(StunMessageEvent evt)
|
||||
public synchronized void processResponse(StunResponseEvent evt)
|
||||
{
|
||||
synchronized(sendLock)
|
||||
{
|
||||
|
||||
@ -317,7 +317,7 @@ public class MessageEventDispatchingTest extends TestCase
|
||||
* @param response a <tt>StunMessageEvent</tt> which describes the
|
||||
* received STUN <tt>Response</tt>
|
||||
*/
|
||||
public synchronized void processResponse(StunMessageEvent response)
|
||||
public synchronized void processResponse(StunResponseEvent response)
|
||||
{
|
||||
receivedResponses.add(response);
|
||||
notifyAll();
|
||||
|
||||
@ -556,7 +556,7 @@ public class TransactionSupportTests extends TestCase
|
||||
*
|
||||
* @param response the event to log.
|
||||
*/
|
||||
public void processResponse(StunMessageEvent response)
|
||||
public void processResponse(StunResponseEvent response)
|
||||
{
|
||||
receivedResponses.add(response);
|
||||
}
|
||||
|
||||
@ -339,7 +339,7 @@ public class ShallowStackTest extends TestCase {
|
||||
* @param response a <tt>StunMessageEvent</tt> which describes the
|
||||
* received STUN <tt>Response</tt>
|
||||
*/
|
||||
public synchronized void processResponse(StunMessageEvent response)
|
||||
public synchronized void processResponse(StunResponseEvent response)
|
||||
{
|
||||
collectedResponse = (Response) response.getMessage();
|
||||
logger.finest("Received response.");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user