examples/streaming/video/index.js
function() {
		    //io = socket(process.env.PORT || process.env.NODE_PORT || 3333);
        io = socket(http);

		    io.on('connection', function(socket){
            console.log('connection happened');
			      //Logic for handeling a new connection here.
			      //ie. registering a user or something similar.

			      //The new connection can send commands.
			      socket.on('keydown', function(data) {
				        var index = keysToPress.indexOf(data.key);
				        if(index === -1) {
					          keysToPress.push(data.key);
				        }
			      });

			      socket.on('keyup', function(data) {
				        var index = keysToPress.indexOf(data.key);
				        if(index !== -1) {
					          keysToPress.splice(index, 1);
				        }
			      });

			      socket.on('restart', function(data) {
				        gameboy_instance.loadROM(rom);
			      });

		    });
	  }
function() {
		    //io = socket(process.env.PORT || process.env.NODE_PORT || 3333);
        io = socket(http);

		    io.on('connection', function(socket){
            console.log('connection happened');
			      //Logic for handeling a new connection here.
			      //ie. registering a user or something similar.

			      //The new connection can send commands.
			      socket.on('keydown', function(data) {
				        var index = keysToPress.indexOf(data.key);
				        if(index === -1) {
					          keysToPress.push(data.key);
				        }
			      });

			      socket.on('keyup', function(data) {
				        var index = keysToPress.indexOf(data.key);
				        if(index !== -1) {
					          keysToPress.splice(index, 1);
				        }
			      });

			      socket.on('restart', function(data) {
				        gameboy_instance.loadROM(rom);
			      });

		    });
	  }
function ( ) { //io = socket(process.env.PORT || process.env.NODE_PORT || 3333); io = socket ( http ) ; io . on ( 'connection' , function ( socket ) { console . log ( 'connection happened' ) ; //Logic for handeling a new connection here. //ie. registering a user or something similar. //The new connection can send commands. socket . on ( 'keydown' , function ( data ) { var index = keysToPress . indexOf ( data . key ) ; if ( index === - 1 ) { keysToPress . push ( data . key ) ; } } ) ; socket . on ( 'keyup' , function ( data ) { var index = keysToPress . indexOf ( data . key ) ; if ( index !== - 1 ) { keysToPress . splice ( index , 1 ) ; } } ) ; socket . on ( 'restart' , function ( data ) { gameboy_instance . loadROM ( rom ) ; } ) ; } ) ; }
What keys we want pressed.
What keys we want pressed .