CC-3430: Live Stream: Admin should be able to kick out the source connection

- Clicking a button on UI triggers sending msg to pypo, which will lead running
'kick' command in liquidsoap.
This commit is contained in:
James 2012-03-14 11:09:59 -04:00
parent 2ee4b227fc
commit c5c9fd7ba8
6 changed files with 50 additions and 6 deletions

View File

@ -7,6 +7,7 @@ class DashboardController extends Zend_Controller_Action
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('switch-source', 'json')
->addActionContext('disconnect-source', 'json')
->initContext();
}
@ -15,9 +16,17 @@ class DashboardController extends Zend_Controller_Action
// action body
}
public function disconnectSourceAction(){
$request = $this->getRequest();
$sourcename = $request->getParam('sourcename');
$data = array("sourcename"=>$sourcename);
Application_Model_RabbitMq::SendMessageToPypo("disconnect_source", $data);
}
public function switchSourceAction(){
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$sourcename = $this->_getParam('sourcename');
$current_status = $this->_getParam('status');
$change_status_to = "on";

View File

@ -33,7 +33,7 @@
</li>
<li>
<div id="live_dj_div">
<?php if($this->isAdmin){?><a id="live_dj_connection" class="source-kick-button" onclick="kickSource(this)"></a><?php }?>
<?php if($this->isAdmin){?><a id="live_dj" class="source-kick-button" onclick="kickSource(this)"></a><?php }?>
Live DJ
<div class="line-to-on-air off"></div>
<a href="#" id="live_dj" class="source-switch-button" onclick="<?php echo ($this->isAdmin)?"setSwitchListener(this);":"return false"?>"><span><?php echo $this->live_dj_switch?></span></a>
@ -42,7 +42,7 @@
</li>
<li>
<div id="master_dj_div">
<?php if($this->isAdmin){?><a id="master_dj_connection" class="source-kick-button" onclick="kickSource(this)"></a><?php }?>
<?php if($this->isAdmin){?><a id="master_dj" class="source-kick-button" onclick="kickSource(this)"></a><?php }?>
Master DJ
<div class="line-to-on-air off"></div>
<a href="#" id="master_dj" class="source-switch-button" onclick="<?php echo ($this->isAdmin)?"setSwitchListener(this);":"return false"?>"><span><?php echo $this->master_dj_switch?></span></a>

View File

@ -422,7 +422,7 @@ select {
display:block;
}
.source-connection {
.source-kick-button {
border:1px solid #242424;
color:#fff;
min-height:14px;
@ -432,6 +432,11 @@ select {
float: left;
}
.source-kick-button:hover{
cursor:pointer;
background-color:#FFFFFF;
}
.line-to-switch {
float: right;
width: 10px;

View File

@ -363,7 +363,14 @@ function setSwitchListener(ele){
}
function kickSource(ele){
var sourcename = $(ele).attr('id')
var source_connection = $(ele).parent().find(".line-to-switch").attr("class")
if(source_connection.indexOf("off") > 0){
alert("No source is connected to this input.")
return false
}else{
$.get("/Dashboard/disconnect-source/format/json/sourcename/"+sourcename)
}
}
var stream_window = null;

View File

@ -95,13 +95,33 @@ class PypoFetch(Thread):
elif command == 'switch_source':
self.logger.info("switch_on_source show command received...")
self.switch_source(m['sourcename'], m['status'])
elif command == 'disconnect_source':
self.logger.info("disconnect_on_source show command received...")
self.disconnect_source(m['sourcename'])
except Exception, e:
import traceback
top = traceback.format_exc()
self.logger.error('Exception: %s', e)
self.logger.error("traceback: %s", top)
self.logger.error("Exception in handling Message Handler message: %s", e)
def disconnect_source(self,sourcename):
self.logger.debug('Disconnecting source: %s', sourcename)
command = ""
if(sourcename == "master_dj"):
command += "master_harbor.kick\n"
elif(sourcename == "live_dj"):
command += "live_dj_harbor.kick\n"
try:
tn = telnetlib.Telnet(LS_HOST, LS_PORT)
tn.write(command)
tn.write('exit\n')
tn.read_all()
except Exception, e:
self.logger.debug(e)
self.logger.debug('Could not connect to liquidsoap')
def switch_source(self, sourcename, status):
self.logger.debug('Switching source: %s to "%s" status', sourcename, status)
command = "streams."

View File

@ -77,6 +77,9 @@ class PypoMessageHandler(Thread):
elif command == 'switch_source':
self.logger.info("switch_source command received...")
self.pypo_queue.put(message)
elif command == 'disconnect_source':
self.logger.info("disconnect_source command received...")
self.pypo_queue.put(message)
elif command == 'update_recorder_schedule':
self.recorder_queue.put(message)
elif command == 'cancel_recording':