Skip to content

Commit

Permalink
Added start/stop functionality for components
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaheer Abbas Merali committed Nov 14, 2010
1 parent 25d0251 commit 9e6c9e9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
18 changes: 15 additions & 3 deletions flumotion2stomp.html
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,19 @@
$('#' + comp).toggleClass("unselected");
$('#' + comp).toggleClass("selected");
$('#selectedcomponents').html('Selected components: ');
$.each($('.selected'), function(index, value) { $('#selectedcomponents').append(value + '<br />'); });
$.each($('.selected'), function(index, value) { compname = value.childNodes[0].textContent; console.log('component ' + value + " name " + compname); $('#selectedcomponents').append(compname + '<br />'); });
}

function start_selected_components() {
$.each($('.selected'), function(index, value) { compname = value.childNodes[0].textContent; console.log("starting component " + compname); message = { "component": compname, "command": "componentStart"}; stomp.send(JSON.stringify(message), COMMAND_CHANNEL); });
$('.selected').toggleClass('unselected');
$('.selected').toggleClass('selected');
}

function stop_selected_components() {
$.each($('.selected'), function(index, value) { compname = value.childNodes[0].textContent; console.log("stopping component " + compname); message = { "component": compname, "command": "componentStop"}; stomp.send(JSON.stringify(message), COMMAND_CHANNEL); });
$('.selected').toggleClass('unselected');
$('.selected').toggleClass('selected');
}

$(document).ready(function() {
Expand Down Expand Up @@ -324,8 +336,8 @@
stomp.connect("localhost", 61613); //, 'guest', 'guest');
$('#startallrecordings').styledButton({'action': function() { start_all_recordings(); } });
$('#stopallrecordings').styledButton({'action': function() { stop_all_recordings(); } });
$('#startcomponent').styledButton({'action': function() { console.log("Starting components"); } });
$('#stopcomponent').styledButton({'action': function() { console.log("Stopping components"); } });
$('#startcomponent').styledButton({'action': function() { start_selected_components(); } });
$('#stopcomponent').styledButton({'action': function() { stop_selected_components(); } });

});
</script>
Expand Down
18 changes: 15 additions & 3 deletions flumotion2stomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ def run_command(self, message):
params = message.get("params", [])
method = message.get("method", None)
# allow only specific commands
if command not in ["componentCallRemote", "invokeOnComponents"]:
if command not in ["componentCallRemote", "invokeOnComponents", "componentStart", "componentStop"]:
return False
if not component or not method:
if not component:
return False
state = None
if command == "invokeOnComponents":
Expand All @@ -265,10 +265,22 @@ def run_command(self, message):
if c.get('name') == component:
state = c
break
if command in ["componentStart", "componentStop"]:
need_method = False
else:
need_method = True
if need_method and not_method:
print "need method but none specified"
return False
if not state:
print "component %s not found" % (component,)
return False
try:
d = self.model.callRemote(command, state, method)
print "about to run %s on %r" % (command, state)
if need_method:
d = self.model.callRemote(command, state, method)
else:
d = self.model.callRemote(command, state)
return d
except Exception, e:
print "Got exception %r running %s" % (e, command)
Expand Down

0 comments on commit 9e6c9e9

Please sign in to comment.