bigbluebutton-Github/bigbluebutton-web/grails-app/services/org/bigbluebutton/pbx/asterisk/AsteriskAgiService.groovy
Richard Alam 56aeba1abf - convert print to log
git-svn-id: http://bigbluebutton.googlecode.com/svn/trunk@2107 af16638f-c34d-0410-8cfa-b39d5352b314
2009-08-05 17:53:19 +00:00

65 lines
2.3 KiB
Groovy

/*
* BigBlueButton - http://www.bigbluebutton.org
*
* Copyright (c) 2008-2009 by respective authors (see below). All rights reserved.
*
* BigBlueButton is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 3 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, If not, see <http://www.gnu.org/licenses/>.
*
* $Id: $
*/
package org.bigbluebutton.pbx.asterisk
import org.asteriskjava.fastagi.AgiChannel
import org.asteriskjava.fastagi.AgiException
import org.asteriskjava.fastagi.AgiHangupException
import org.asteriskjava.fastagi.AgiRequest
import org.asteriskjava.fastagi.AgiScript
import java.util.Calendar
import org.bigbluebutton.web.domain.ScheduledSession
class AsteriskAgiService implements AgiScript {
private long _10_minutes = 10*60*1000
public void service(AgiRequest request, AgiChannel channel)
throws AgiException {
def number = request.getParameter("conference")
log.debug "Looking for conference $number"
def conf = ScheduledSession.findByVoiceConferenceBridge(number)
if (conf) {
log.debug("found conference " + conf.name)
def startTime = conf.startDateTime.time - _10_minutes
def endTime = conf.endDateTime.time + _10_minutes
def now = new Date()
log.debug("startTime " + new Date(startTime) + " endTime " + new Date(endTime) + " now " + now)
if ((startTime < now.time) && (endTime > now.time)) {
log.debug("Setting channel var CONFERENCE_FOUND to $number")
channel.setVariable("CONFERENCE_FOUND", number)
} else {
log.debug("The conference $number has no schedule at this moment")
channel.setVariable("CONFERENCE_FOUND", "0")
}
} else {
log.debug("Could not find conference $number")
channel.setVariable("CONFERENCE_FOUND", "0")
}
}
}