Skip to content

About

Tiny training on Node & Socket.IO

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chat using Node/Express & Socket.io (with data backup by Redis)

Intro

A small real time chat build with Node/Express using Redis.

Redis is required (storage of users and messages, IP included).

Installation

yarn install to install dependencies.

Run node server with yarn start and follow instructions (server run on http://localhost:3000)

API

Connection and other Events

client will emit some events about the state of the connection to the Redis server.

Receive

Open socket on client side.

const socket = io();

chat.join (receive)

  • username is mandatory (any valid string)
socket.emit('chat.join', username);

chat.message (receive)

  • message is mandatory (any valid string)
socket.emit('chat.message', message);

Emit

chat.join (emit)

{
  "username": "John DOE"
}

chat.message (emit)

{
  "username": "John DOE",
  "message": "Lorem Ipsum"
}

chat.disconnect (emit)

{
  "username": "John DOE"
}

About

Tiny training on Node & Socket.IO

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages