Skip to content

Nodejs WebSocket(ws package) chatrooms server with client->server commands

Notifications You must be signed in to change notification settings

benlazzero/WebSocket-Chat-Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nodejs WebSocket chatrooms server using 'ws'

'Not so simple' handshake and everyone get's upgraded!

The server is using a 2d matrix to handle rooms and the users in each. This can be seen as a class variable in roomManager.js. I had seen other implementations for rooms such as adding the room to the user object, but this created headaches for handling simple methods like broadcast or leave-room. All client-server interaction is handled by parsing client messages over the connection.

Server features:

  1. username created upon connection (bounds enforced: no whitespace, > 3 chars, < 8 chars)
  2. create/join rooms
  3. list current rooms and the number of users in rooms
  4. chat broadcasted to users in the same room e.g 'tom35: hello'

Commands

To join a room or create if does not exist.

\r (room name)

To leave the current room.

/q

To list all rooms and the number of users in each room.

\l

About

Nodejs WebSocket(ws package) chatrooms server with client->server commands

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published