use of javax.slee.facilities.TimerID in project charging-server by RestComm.
the class DiameterChargingServerSbb method sendCCA.
/**
* Sends the Credit-Control-Answer through the ACI and detaches if set to.
* @param cca the Credit-Control-Answer to send
* @param aci the ACI where to send from
* @param detach boolean indicating whether to detach or not
* @return true if it succeeds sending, false otherwise
*/
private boolean sendCCA(RoCreditControlAnswer cca, ActivityContextInterface aci, boolean detach) {
// Start by cancelling any existing Timer
TimerID timerID = getTimerID();
if (timerID != null) {
timerFacility.cancelTimer(timerID);
if (tracer.isFineEnabled()) {
tracer.info("[><] " + sidString + " Cancelling existing timer " + timerID);
}
}
// Set a new one, unless we are leaving...
if (!detach) {
timerID = timerFacility.setTimer(aci, null, System.currentTimeMillis() + DEFAULT_VALIDITY_TIME * 1000, DEFAULT_TIMER_OPTIONS);
setTimerID(timerID);
if (tracer.isFineEnabled()) {
tracer.fine("[><] " + sidString + " Setting new timer " + timerID + " for " + System.currentTimeMillis() + DEFAULT_VALIDITY_TIME * 1000);
}
}
try {
RoServerSessionActivity ccServerActivity = (RoServerSessionActivity) aci.getActivity();
ccServerActivity.sendRoCreditControlAnswer(cca);
if (detach) {
if (tracer.isFineEnabled()) {
tracer.fine("[><] " + sidString + " Detaching from ACI.");
}
aci.detach(this.getSbbContext().getSbbLocalObject());
}
return true;
} catch (IOException e) {
tracer.severe("[xx] " + sidString + " Error while trying to send Credit-Control-Answer.", e);
return false;
}
}
use of javax.slee.facilities.TimerID in project smscgateway by RestComm.
the class DeliveryCommonSbb method cancelDeliveryTimer.
protected void cancelDeliveryTimer() {
TimerID timer = this.getDeliveryTimerID();
setDeliveryTimerID(null);
if (this.timerFacility != null && timer != null)
this.timerFacility.cancelTimer(timer);
}
use of javax.slee.facilities.TimerID in project smscgateway by RestComm.
the class DeliveryCommonSbb method rescheduleDeliveryTimer.
// *********
// Methods for managing of delivery timeout
protected void rescheduleDeliveryTimer(int smsSetSize) {
this.cancelDeliveryTimer();
if (this.timerFacility != null) {
int multiplier = getMaxMessagesPerStep() != null ? Math.min(smsSetSize, getMaxMessagesPerStep()) : smsSetSize;
int adaptedDeliveryTimeout = smscPropertiesManagement.getDeliveryTimeout() + smscPropertiesManagement.getDeliveryTimeoutDeltaPerMessage() * multiplier;
long startTime = System.currentTimeMillis() + 1000 * adaptedDeliveryTimeout;
TimerOptions options = new TimerOptions();
ActivityContextInterface activity = getSchedulerActivityContextInterface();
TimerID timer = this.timerFacility.setTimer(activity, null, startTime, options);
setDeliveryTimerID(timer);
}
}
Aggregations