Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added listener mode for Cyclops

  • Loading branch information...
commit f74fb80db840544f52e8594b43b7057005e8fe14 1 parent a30bf06
Andre Goncalves andregoncalves authored
Showing with 27 additions and 6 deletions.
  1. +20 −4 assets/javascripts/cymain.js
  2. +7 −2 assets/javascripts/demo2.js
24 assets/javascripts/cymain.js
View
@@ -1,9 +1,25 @@
var Cyclops = {
- init:function() {
+ init_as: function(type) {
this.eventStorage = {};
- pubsub.subscribe('/record/start', this, "startRecording");
- pubsub.subscribe('/record/stop', this, "stopRecording");
+
+ if (type == "master")
+ {
+ pubsub.subscribe('/record/start', this, "startRecording");
+ pubsub.subscribe('/record/stop', this, "stopRecording");
+ }
+ else
+ {
+ pubsub.subscribe('/listen/start', this, 'startListening');
+ }
+ },
+
+ startListening: function() {
+ $.get("/activity?id=final", {}, function(ev) {
+ ev = JSON.parse(ev);
+ this['playEvent_'+ev.type](ev.data);
+ this.startListening();
+ });
},
startRecording: function(e) {
@@ -22,7 +38,7 @@ var Cyclops = {
sendEvent: function(e) {
ev = this['getEvent_'+e.type](e);
- $.post('/publish?id=demo2', ev.serialize(), function(data, textStatus) {
+ $.post('/publish?id=final', ev.serialize(), function(data, textStatus) {
if (textStatus != "success")
console.info("failed posting! " + stextStatus);
});
9 assets/javascripts/demo2.js
View
@@ -1,9 +1,10 @@
$(document).ready(function() {
- window.pubsub = new PubSub('/record/start', '/record/stop');
+ window.pubsub = new PubSub('/record/start', '/record/stop', '/listen/start', '/listen/stop');
CyNotify.subscribe('/record/start');
CyNotify.subscribe('/record/stop');
+ CyNotify.subscribe('/listen/start');
/*e = new CyEvent("mousemove", { x:10, y:20});
@@ -15,7 +16,7 @@ $(document).ready(function() {
});
$(window).load(function() {
- Cyclops.init();
+ Cyclops.init_as('slave');
$(document).bind('keydown', 'Ctrl+r', function(e) {
pubsub.publish('/record/start', e, 'recording started');
@@ -25,6 +26,10 @@ $(window).load(function() {
pubsub.publish('/record/stop', e, 'recording stopped');
});
+ $(document).bind('keydown', 'Ctrl+l', function(e) {
+ pubsub.publish('/listen/start', e, 'listen started');
+ });
+
/* $('img').click(function(e) {
console.info(e);
console.info("click on image");
Please sign in to comment.
Something went wrong with that request. Please try again.