Merge branch 'master' of dev.sourcefabric.org:campcaster
This commit is contained in:
commit
e57b18168a
8 changed files with 64 additions and 37 deletions
|
@ -3,30 +3,41 @@ require_once 'php-amqplib/amqp.inc';
|
|||
|
||||
class RabbitMq
|
||||
{
|
||||
static private $doPush = FALSE;
|
||||
|
||||
/**
|
||||
* Sets a flag to push the schedule at the end of the request.
|
||||
*/
|
||||
public static function PushSchedule() {
|
||||
RabbitMq::$doPush = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push the current schedule to RabbitMQ, to be picked up by Pypo.
|
||||
* Will push the schedule in the range from 24 hours ago to 24 hours
|
||||
* in the future.
|
||||
*/
|
||||
public static function PushSchedule() {
|
||||
public static function PushScheduleFinal()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$conn = new AMQPConnection($CC_CONFIG["rabbitmq"]["host"],
|
||||
$CC_CONFIG["rabbitmq"]["port"],
|
||||
$CC_CONFIG["rabbitmq"]["user"],
|
||||
$CC_CONFIG["rabbitmq"]["password"]);
|
||||
$channel = $conn->channel();
|
||||
$channel->access_request($CC_CONFIG["rabbitmq"]["vhost"], false, false, true, true);
|
||||
if (RabbitMq::$doPush) {
|
||||
$conn = new AMQPConnection($CC_CONFIG["rabbitmq"]["host"],
|
||||
$CC_CONFIG["rabbitmq"]["port"],
|
||||
$CC_CONFIG["rabbitmq"]["user"],
|
||||
$CC_CONFIG["rabbitmq"]["password"]);
|
||||
$channel = $conn->channel();
|
||||
$channel->access_request($CC_CONFIG["rabbitmq"]["vhost"], false, false, true, true);
|
||||
|
||||
$EXCHANGE = 'airtime-schedule';
|
||||
$channel->exchange_declare($EXCHANGE, 'direct', false, true);
|
||||
$EXCHANGE = 'airtime-schedule';
|
||||
$channel->exchange_declare($EXCHANGE, 'direct', false, true);
|
||||
|
||||
$data = json_encode(Schedule::ExportRangeAsJson());
|
||||
$msg = new AMQPMessage($data, array('content_type' => 'text/plain'));
|
||||
$data = json_encode(Schedule::ExportRangeAsJson());
|
||||
$msg = new AMQPMessage($data, array('content_type' => 'text/plain'));
|
||||
|
||||
$channel->basic_publish($msg, $EXCHANGE);
|
||||
$channel->close();
|
||||
$conn->close();
|
||||
$channel->basic_publish($msg, $EXCHANGE);
|
||||
$channel->close();
|
||||
$conn->close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -716,7 +716,7 @@ class Schedule {
|
|||
$result['stream_metadata'] = array();
|
||||
$result['stream_metadata']['format'] = Application_Model_Preference::GetStreamLabelFormat();
|
||||
$result['stream_metadata']['station_name'] = Application_Model_Preference::GetStationName();
|
||||
$result['server_timezone'] = date_default_timezone_get();
|
||||
$result['server_timezone'] = date('O');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue