Creating a real-time server
Now let's create a real-time web server to allow us to control the strip from a web page that can be accessed from any browser. We'll be building two web pages: one to control the strip and another to play YouTube videos from a playlist.
To enable real-time communication, we'll be using the Socket.IO real-time engine. In the SSH shell and inside the project folder, install the Socket.IO Node.js module using the npm install socket.io
command. The operation will install some dependencies and will take a couple of minutes to conclude.
Socket.IO allows us to exchange real-time messages between our web pages and our server.
Galileo will run the server, while the browsers will run the clients. Clients will connect to the server and bidirectional communication channels will be established between each of them.
Create a new file, name it index.js
, and paste the following code:
var fs = require('fs'); var routesViews = { '/player': 'youtubePlayer.html', '/controls': 'controls...