aboutsummaryrefslogtreecommitdiff
path: root/plugin/notes-server
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2015-09-29 10:07:21 +0200
committerHakim El Hattab <hakim.elhattab@gmail.com>2015-09-29 10:07:21 +0200
commitb16bc6fc2e948dedf597004fb99e69d4042daa47 (patch)
tree7fbcdd466e7c3a1109cc602500950a9f86a0beba /plugin/notes-server
parent5117048a5b86212a35d5309775a0ac646b1bd30c (diff)
downloadfreenode-live-2017-presentation-b16bc6fc2e948dedf597004fb99e69d4042daa47.tar
freenode-live-2017-presentation-b16bc6fc2e948dedf597004fb99e69d4042daa47.tar.gz
speaker notes work with socket.io 1.0 #1375
Diffstat (limited to 'plugin/notes-server')
-rw-r--r--plugin/notes-server/client.js2
-rw-r--r--plugin/notes-server/index.js22
-rw-r--r--plugin/notes-server/notes.html16
3 files changed, 21 insertions, 19 deletions
diff --git a/plugin/notes-server/client.js b/plugin/notes-server/client.js
index 628586f..719b495 100644
--- a/plugin/notes-server/client.js
+++ b/plugin/notes-server/client.js
@@ -41,7 +41,7 @@
}
// When a new notes window connects, post our current state
- socket.on( 'connect', function( data ) {
+ socket.on( 'new-subscriber', function( data ) {
post();
} );
diff --git a/plugin/notes-server/index.js b/plugin/notes-server/index.js
index df917f1..75838de 100644
--- a/plugin/notes-server/index.js
+++ b/plugin/notes-server/index.js
@@ -1,23 +1,25 @@
+var http = require('http');
var express = require('express');
var fs = require('fs');
var io = require('socket.io');
var _ = require('underscore');
var Mustache = require('mustache');
-var app = express.createServer();
+var app = express();
var staticDir = express.static;
+var server = http.createServer(app);
-io = io.listen(app);
+io = io(server);
var opts = {
port : 1947,
baseDir : __dirname + '/../../'
};
-io.sockets.on( 'connection', function( socket ) {
+io.on( 'connection', function( socket ) {
- socket.on( 'connect', function( data ) {
- socket.broadcast.emit( 'connect', data );
+ socket.on( 'new-subscriber', function( data ) {
+ socket.broadcast.emit( 'new-subscriber', data );
});
socket.on( 'statechanged', function( data ) {
@@ -26,12 +28,8 @@ io.sockets.on( 'connection', function( socket ) {
});
-app.configure( function() {
-
- [ 'css', 'js', 'images', 'plugin', 'lib' ].forEach( function( dir ) {
- app.use( '/' + dir, staticDir( opts.baseDir + dir ) );
- });
-
+[ 'css', 'js', 'images', 'plugin', 'lib' ].forEach( function( dir ) {
+ app.use( '/' + dir, staticDir( opts.baseDir + dir ) );
});
app.get('/', function( req, res ) {
@@ -52,7 +50,7 @@ app.get( '/notes/:socketId', function( req, res ) {
});
// Actually listen
-app.listen( opts.port || null );
+server.listen( opts.port || null );
var brown = '\033[33m',
green = '\033[32m',
diff --git a/plugin/notes-server/notes.html b/plugin/notes-server/notes.html
index 72d0317..d924ad9 100644
--- a/plugin/notes-server/notes.html
+++ b/plugin/notes-server/notes.html
@@ -195,7 +195,6 @@
if( connected === false ) {
connected = true;
- setupIframes( data );
setupKeyboard();
setupNotes();
setupTimer();
@@ -206,13 +205,19 @@
} );
+ // Load our presentation iframes
+ setupIframes();
+
+ // Once the iframes have loaded, emit a signal saying there's
+ // a new subscriber which will trigger a 'statechanged'
+ // message to be sent back
window.addEventListener( 'message', function( event ) {
var data = JSON.parse( event.data );
if( data && data.namespace === 'reveal' ) {
if( /ready/.test( data.eventName ) ) {
- socket.emit( 'connect', { socketId: socketId } );
+ socket.emit( 'new-subscriber', { socketId: socketId } );
}
}
@@ -267,7 +272,7 @@
/**
* Creates the preview iframes.
*/
- function setupIframes( data ) {
+ function setupIframes() {
var params = [
'receiver',
@@ -277,9 +282,8 @@
'backgroundTransition=none'
].join( '&' );
- var hash = '#/' + data.state.indexh + '/' + data.state.indexv;
- var currentURL = '/?' + params + '&postMessageEvents=true' + hash;
- var upcomingURL = '/?' + params + '&controls=false' + hash;
+ var currentURL = '/?' + params + '&postMessageEvents=true';
+ var upcomingURL = '/?' + params + '&controls=false';
currentSlide = document.createElement( 'iframe' );
currentSlide.setAttribute( 'width', 1280 );