No description, website, or topics provided.
JavaScript HTML
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
public
.babelrc
.gitignore
README.md
docker-compose.yaml
index.js
package.json
redis-helper.js
server.js
webpack.config.js
yarn.lock

README.md

Example: Notification from backend with Socket.io and Redis

This sample is demonstrating sending events via socket, which coming from where isn't Socket.io context. e.g. database, batch, etc. To send those events to browsers via socket, it can be achieved with socket.io-emitter. Also, I combined this sample with Redis to proof scalability.

Prerequisites

Docker for Mac/Windows, etc. I'm using docker-compose.

Set up

Running Redis

$ docker-compose up

If you want to stop docker, just hit Ctrl+C.

Quick redis-cli memo.

$ redis-cli # connect to redis
$ > flushall # delete all
$ > keys * # check all keys
$ > get <key> # get value

You can install redis-cli via brew install redis.

Install dependencies

$ npm install

Build client's source codes

$ npm run build

Demo

Run server with port 3000

$ node index.js 3000

Run server with port 4000

$ node index.js 4000

You can send message to specific users.

Remarks

If you're interested in case of separated socket.io server. I've prepared demo for that case too, on different branch.