diff --git a/src/org/ice4j/ResponseCollector.java b/src/org/ice4j/ResponseCollector.java
index afba139..0b6abcb 100644
--- a/src/org/ice4j/ResponseCollector.java
+++ b/src/org/ice4j/ResponseCollector.java
@@ -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
diff --git a/src/org/ice4j/ice/checks/ConnectivityCheckClient.java b/src/org/ice4j/ice/checks/ConnectivityCheckClient.java
index 6ee4069..21fcaea 100644
--- a/src/org/ice4j/ice/checks/ConnectivityCheckClient.java
+++ b/src/org/ice4j/ice/checks/ConnectivityCheckClient.java
@@ -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)
diff --git a/src/org/ice4j/ice/harvest/StunCandidateHarvester.java b/src/org/ice4j/ice/harvest/StunCandidateHarvester.java
index db423dc..e7ea8d7 100644
--- a/src/org/ice4j/ice/harvest/StunCandidateHarvester.java
+++ b/src/org/ice4j/ice/harvest/StunCandidateHarvester.java
@@ -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)
{
diff --git a/src/org/ice4j/stack/StunClientTransaction.java b/src/org/ice4j/stack/StunClientTransaction.java
index e09511e..8088413 100644
--- a/src/org/ice4j/stack/StunClientTransaction.java
+++ b/src/org/ice4j/stack/StunClientTransaction.java
@@ -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));
}
/**
diff --git a/src/org/ice4j/stunclient/BlockingRequestSender.java b/src/org/ice4j/stunclient/BlockingRequestSender.java
index f11353c..6f884ed 100644
--- a/src/org/ice4j/stunclient/BlockingRequestSender.java
+++ b/src/org/ice4j/stunclient/BlockingRequestSender.java
@@ -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)
{
diff --git a/test/org/ice4j/MessageEventDispatchingTest.java b/test/org/ice4j/MessageEventDispatchingTest.java
index baf33f5..1fc91bc 100644
--- a/test/org/ice4j/MessageEventDispatchingTest.java
+++ b/test/org/ice4j/MessageEventDispatchingTest.java
@@ -317,7 +317,7 @@ public class MessageEventDispatchingTest extends TestCase
* @param response a StunMessageEvent which describes the
* received STUN Response
*/
- public synchronized void processResponse(StunMessageEvent response)
+ public synchronized void processResponse(StunResponseEvent response)
{
receivedResponses.add(response);
notifyAll();
diff --git a/test/org/ice4j/TransactionSupportTests.java b/test/org/ice4j/TransactionSupportTests.java
index e51ea6b..19b137f 100644
--- a/test/org/ice4j/TransactionSupportTests.java
+++ b/test/org/ice4j/TransactionSupportTests.java
@@ -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);
}
diff --git a/test/org/ice4j/stack/ShallowStackTest.java b/test/org/ice4j/stack/ShallowStackTest.java
index a319154..5a4d3a2 100644
--- a/test/org/ice4j/stack/ShallowStackTest.java
+++ b/test/org/ice4j/stack/ShallowStackTest.java
@@ -339,7 +339,7 @@ public class ShallowStackTest extends TestCase {
* @param response a StunMessageEvent which describes the
* received STUN Response
*/
- public synchronized void processResponse(StunMessageEvent response)
+ public synchronized void processResponse(StunResponseEvent response)
{
collectedResponse = (Response) response.getMessage();
logger.finest("Received response.");