We will handle WebSocket connections using the socket.io library. This is the most used WebSocket library for the Node.js community.
Now, let's start our WebSocket implementation. Open your index.js file and put this code inside it:
let Rx = require('rx'); let dataSource = require('./data_source'); let services = require('./services')(dataSource);
For now, we've just imported reactive extensions, our DataSource, and created our services. Now we need to start the server:
let app = require('express')(); let http = require('http').Server(app); let io = require('socket.io')(http); http.listen(3000,()=>console.log('Server listening on port 3000'));
Here, we create an HTTP server, pass it to the socket.io library, ...