Skip to content

Latest commit

 

History

History
118 lines (105 loc) · 1.54 KB

File metadata and controls

118 lines (105 loc) · 1.54 KB

WebSocket Client Instance Manager

Kind of like a mutant in-between a boilerplate and a framework for building multi-user WebSocket applications over several client instances.

Installation

Development

  • npm install
  • npm run dev runs the development environment using webpack-dev-server + hot reload

Deployment

  • npm run dist builds the production distribution package for JS, CSS and other assets
  • npm run start start-up script

Requests And Responses

Query User

Request
socket.emit('query', data)
data = {
  "type": "user"
}
Response
socket.on('query', callback)
{
  "type": "user",
  "data": {
    "name": "Nyan"
  }
}

Query Instance

Request
socket.emit('query', data)
data = {
  "type": "instance",
  "id"  : "QWERTY"
}
Response
socket.on('query', callback)
{
  "type": "instance",
  "data": {
    "id"    : "QWERTY",
    "status": "waiting",
    "users" : []
  }
}

Join Instance

Request
socket.emit('join', data)
data = {
  "id": "QWERTY"
}
Response
socket.on('query', data)

Speak Instance

Request
socket.emit('speak', data)
data = {
  "message": "Hello!"
}
Response
socket.on('speak', callback)
{
  "name"  : "Nyan",
  "message: "Hello!"
}

Leave Instance

Request
socket.emit('leave', data)
data: {
  "id": "QWERTY"
}
Response
socket.on('query', data)