Prevents more than one conference-info NOTIFY being sent to a single SIP CallPeer in an interval of 200ms

cusax-fix
Boris Grozev 13 years ago
parent 90d6494be9
commit c0d246bd70

@ -71,17 +71,6 @@ public class CallPeerJabberImpl
*/
private final Object sidSyncRoot = new Object();
/**
* Whether a COIN has been scheduled to be sent to this
* <tt>CallPeerJabberImpl</tt>
*/
private boolean coinScheduled = false;
/**
* Synchronization object for coinScheduled
*/
private final Object coinScheduledSyncRoot = new Object();
/**
* Creates a new call peer with address <tt>peerAddress</tt>.
*
@ -1465,34 +1454,6 @@ else if (((IQ) result).getType() != IQ.Type.RESULT)
}
}
/**
* Check whether a COIN is scheduled to be sent to this <tt>CallPeer</tt>
* (i.e. there is a thread which will eventually (after sleeping a certain
* amount of time) trigger a COIN to be sent)
* @return <tt>true</tt> if there is a COIN scheduled to be sent to this
* <tt>CallPeer</tt> and <tt>false</tt> otherwise
*/
public boolean isCoinScheduled()
{
synchronized (coinScheduledSyncRoot)
{
return coinScheduled;
}
}
/**
* Sets the property which indicates whether a COIN is scheduled to be sent
* to this <tt>CallPeer</tt>.
* @param coinScheduled
*/
public void setCoinScheduled(boolean coinScheduled)
{
synchronized (coinScheduledSyncRoot)
{
this.coinScheduled = coinScheduled;
}
}
/**
* {@inheritDoc}
*/

@ -119,11 +119,11 @@ private void notify(CallPeer callPeer)
- callPeerJabber.getLastConferenceInfoSentTimestamp();
if (timeSinceLastCoin < COIN_MIN_INTERVAL)
{
if (callPeerJabber.isCoinScheduled())
if (callPeerJabber.isConfInfoScheduled())
return;
logger.info("Scheduling to send a COIN to " + callPeerJabber);
callPeerJabber.setCoinScheduled(true);
callPeerJabber.setConfInfoScheduled(true);
new Thread(new Runnable(){
@Override
public void run()
@ -157,7 +157,7 @@ public void run()
ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE_COIN))
{
logger.info(callPeer.getAddress() + " does not support COIN");
callPeerJabber.setCoinScheduled(false);
callPeerJabber.setConfInfoScheduled(false);
return;
}
}
@ -200,7 +200,7 @@ public void run()
System.currentTimeMillis());
}
}
callPeerJabber.setCoinScheduled(false);
callPeerJabber.setConfInfoScheduled(false);
}
/**

@ -74,6 +74,12 @@ public class OperationSetTelephonyConferencingSipImpl
*/
private static final int SUBSCRIPTION_DURATION = 3600;
/**
* The minimum interval in milliseconds between conference-info NOTIFYs
* sent to a single <tt>CallPeer</tt>.
*/
private static final int MIN_NOTIFY_INTERVAL = 200;
/**
* The <tt>EventPackageNotifier</tt> which implements conference
* event-package notifier support on behalf of this
@ -887,9 +893,9 @@ protected EventPackageNotifier.Subscription createSubscription(
* (conference information) NOTIFYs
*/
@Override
public void notify( Subscription subscription,
String subscriptionState,
String reason)
public void notify( final Subscription subscription,
final String subscriptionState,
final String reason)
throws OperationFailedException
{
ConferenceNotifierSubscription conferenceSubscription
@ -905,6 +911,42 @@ public void notify( Subscription subscription,
OperationFailedException.INTERNAL_ERROR);
}
final long timeSinceLastNotify = System.currentTimeMillis()
- callPeer.getLastConferenceInfoSentTimestamp();
if (timeSinceLastNotify < MIN_NOTIFY_INTERVAL)
{
if (callPeer.isConfInfoScheduled())
return;
logger.info("Scheduling to send a conference-info NOTIFY to "
+ callPeer);
callPeer.setConfInfoScheduled(true);
new Thread(new Runnable(){
@Override
public void run()
{
try
{
Thread.sleep(1 + MIN_NOTIFY_INTERVAL
- timeSinceLastNotify);
}
catch (InterruptedException ie) {}
try
{
ConferenceEventPackageNotifier.this.notify(
subscription, subscriptionState, reason);
}
catch (OperationFailedException e)
{
logger.error("Failed to send NOTIFY request");
}
}
}).start();
return;
}
ConferenceInfoDocument currentConfInfo
= getCurrentConferenceInfo(callPeer);
ConferenceInfoDocument lastSentConfInfo
@ -916,7 +958,10 @@ public void notify( Subscription subscription,
:getConferenceInfoDiff(lastSentConfInfo, currentConfInfo);
if (diff == null)
{
callPeer.setConfInfoScheduled(false);
return; //no change -- no need to send NOTIFY
}
int newVersion
= lastSentConfInfo == null
@ -981,6 +1026,8 @@ public void notify( Subscription subscription,
if (SubscriptionState.TERMINATED.equals(subscriptionState))
removeSubscription(callId, subscription);
callPeer.setConfInfoScheduled(false);
}
}
}

@ -143,12 +143,22 @@ public abstract class MediaAwareCallPeer
*/
private ConferenceInfoDocument lastConferenceInfoReceived = null;
/**
* Whether a conference-info document has been scheduled to be sent to this
* <tt>CallPeer</tt>
*/
private boolean confInfoScheduled = false;
/**
* Synchronization object for confInfoScheduled
*/
private final Object confInfoScheduledSyncRoot = new Object();
/**
* Creates a new call peer with address <tt>peerAddress</tt>.
*
* @param owningCall the call that contains this call peer.
*/
public MediaAwareCallPeer(T owningCall)
{
this.call = owningCall;
@ -1127,4 +1137,32 @@ public int getLastConferenceInfoReceivedVersion()
* element corresponding to this <tt>CallPeer</tt>)
*/
public abstract String getEntity();
/**
* Check whether a conference-info document is scheduled to be sent to
* this <tt>CallPeer</tt> (i.e. there is a thread which will eventually
* (after sleeping a certain amount of time) trigger a document to be sent)
* @return <tt>true</tt> if there is a conference-info document scheduled
* to be sent to this <tt>CallPeer</tt> and <tt>false</tt> otherwise.
*/
public boolean isConfInfoScheduled()
{
synchronized (confInfoScheduledSyncRoot)
{
return confInfoScheduled;
}
}
/**
* Sets the property which indicates whether a conference-info document
* is scheduled to be sent to this <tt>CallPeer</tt>.
* @param confInfoScheduled
*/
public void setConfInfoScheduled(boolean confInfoScheduled)
{
synchronized (confInfoScheduledSyncRoot)
{
this.confInfoScheduled = confInfoScheduled;
}
}
}

Loading…
Cancel
Save