How to do it...

  1. Now, go back to your NodeJS project that was created in the first recipe. Let's download the node.js socket.io dependency:
       ~> npm install express socket.io --save
  1. Socket.io is also event-based and lets us create our custom event for everything we have, plus some native one for connections. Also, we've installed ExpressJS for configuration sake in order to create a socket.io server.
  2. Now after doing that, we need to configure our socket.io server using express. In this case, do as shown in the following code:
      const express = require('express');      const app = express();      app.io = require('socket.io')();      // [*] Configuring our static files.      app.use(express.static('public/'));      // [*] Configuring Routes. app.get('/', (req, res) ...

Get Firebase Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.