aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorhristoterezov <hristo@jitsi.org>2014-05-30 12:19:26 +0300
committerhristoterezov <hristo@jitsi.org>2014-05-30 12:19:26 +0300
commit4d2003a42067d831db82a7ab024198d75afd3445 (patch)
tree737d1c8b338eee9c55b0ea84b5d23147c43abed8 /src
parenta25ca23a2c4208ceb8dbd9f5b8b8e79ac3eb1521 (diff)
downloadjitsi-4d2003a42067d831db82a7ab024198d75afd3445.zip
jitsi-4d2003a42067d831db82a7ab024198d75afd3445.tar.gz
jitsi-4d2003a42067d831db82a7ab024198d75afd3445.tar.bz2
Adds check for the peer state before sending ringing responses to received invite.
Diffstat (limited to 'src')
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java65
1 files changed, 27 insertions, 38 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java
index f989673..b55999f 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java
@@ -447,41 +447,29 @@ public class CallSipImpl
{
if (logger.isTraceEnabled())
logger.trace("will send ringing response: ");
- response = messageFactory.createResponse(Response.RINGING, invite);
- serverTran.sendResponse(response);
-
- if(serverTran instanceof SIPTransaction
- && !((SIPTransaction)serverTran).isReliable()
- && peer.getState().equals(CallPeerState.INCOMING_CALL))
+ if(peer.getState().equals(CallPeerState.INCOMING_CALL))
{
- final Timer timer = new Timer();
- CallPeerAdapter stateListener = new CallPeerAdapter()
+ response = messageFactory.createResponse(Response.RINGING, invite);
+
+ serverTran.sendResponse(response);
+
+ if(serverTran instanceof SIPTransaction
+ && !((SIPTransaction)serverTran).isReliable())
{
- @Override
- public void peerStateChanged(CallPeerChangeEvent evt)
+ final Timer timer = new Timer();
+ int interval = retransmitsRingingInterval;
+ int delay = 0;
+ for(int i = 0; i < MAX_RETRANSMISSIONS; i++)
{
- if(!evt.getNewValue()
- .equals(CallPeerState.INCOMING_CALL))
- {
- timer.cancel();
- peer.removeCallPeerListener(this);
- }
+ delay += interval;
+ timer.schedule(new RingingResponseTask(response,
+ serverTran, peer, timer), delay);
+ interval *= 2;
}
- };
- int interval = retransmitsRingingInterval;
- int delay = 0;
- for(int i = 0; i < MAX_RETRANSMISSIONS; i++)
- {
- delay += interval;
- timer.schedule(new RingingResponseTask(response,
- serverTran, peer, timer, stateListener), delay);
- interval *= 2;
}
-
- peer.addCallPeerListener(stateListener);
+ if (logger.isDebugEnabled())
+ logger.debug("sent a ringing response: " + response);
}
- if (logger.isDebugEnabled())
- logger.debug("sent a ringing response: " + response);
}
catch (Exception ex)
{
@@ -596,11 +584,6 @@ public class CallSipImpl
private final Timer timer;
/**
- * Listener for the state of the peer.
- */
- private CallPeerAdapter stateListener;
-
- /**
* Create ringing response task.
* @param response the response.
* @param serverTran the transaction.
@@ -609,13 +592,12 @@ public class CallSipImpl
* @param stateListener the state listener.
*/
RingingResponseTask(Response response, ServerTransaction serverTran,
- CallPeerSipImpl peer, Timer timer, CallPeerAdapter stateListener)
+ CallPeerSipImpl peer, Timer timer)
{
this.response = response;
this.serverTran = serverTran;
this.peer = peer;
this.timer = timer;
- this.stateListener = stateListener;
}
/**
@@ -626,12 +608,19 @@ public class CallSipImpl
{
try
{
- serverTran.sendResponse(response);
+ if(!peer.getState().equals(
+ CallPeerState.INCOMING_CALL))
+ {
+ timer.cancel();
+ }
+ else
+ {
+ serverTran.sendResponse(response);
+ }
}
catch (Exception ex)
{
timer.cancel();
- peer.removeCallPeerListener(stateListener);
}
}
}