Search in sources :

Example 1 with TimerID

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;
    }
}
Also used : RoServerSessionActivity(net.java.slee.resource.diameter.ro.RoServerSessionActivity) TimerID(javax.slee.facilities.TimerID) IOException(java.io.IOException)

Example 2 with TimerID

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);
}
Also used : TimerID(javax.slee.facilities.TimerID)

Example 3 with TimerID

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);
    }
}
Also used : ActivityContextInterface(javax.slee.ActivityContextInterface) TimerID(javax.slee.facilities.TimerID) TimerOptions(javax.slee.facilities.TimerOptions)

Aggregations

TimerID (javax.slee.facilities.TimerID)3 IOException (java.io.IOException)1 ActivityContextInterface (javax.slee.ActivityContextInterface)1 TimerOptions (javax.slee.facilities.TimerOptions)1 RoServerSessionActivity (net.java.slee.resource.diameter.ro.RoServerSessionActivity)1