Git Product home page Git Product logo

chat_server's Introduction

Chat Server

Chat server used to manage chats in website

Chat is based on event system communication. All events used client-side and server-side are listed and described here.


Table Of Contents

Starting up

Install all the dependencies using npm install After that, you can run the server using npm start. You can specify the port as following: npm start PORT

Tests

Please put the server adress in tests\configs.js ! Install all the dependencies using npm install First, start a server as described previously. Then, you can run all the tests using npm test


Client-side Events

Client-side events are all events sended by the server to the client.

connection (C)

This event is received when the connection is established with the server. The server will wait for you to send an Auth event or to disconnect. Other sended events will result in a cerror (401 Authentification required).

auth (C)

This event is received when the authentification was succesfuly made ! Exemple of data received:

{
 'Code': 200,
 'message': 'Authentification complete'
}

message (C)

This event is received when a message was sent to the server by a client in the same room. Exemple of data received:

{
 'username': 'nickname',
 'content': 'original message'
}

cerror (C)

This event is received when something unexpected from the client occured. Exemple of data received:

{
 'Code': 401,
 'message': 'Authentification required'
}

Server-side Events

Server-side events are all events clients are allowed to send to the server !

connection (S)

This event is used to establish connection with the server.

disconnect (S)

This event must be sended when disconnecting from the server !

auth (S)

This event is used to authentificate to the server after the connection has been made. It must be sent before sending any other event (except disconnect). Exemple of data sended:

{
 'username': 'nickname',
 'password': 'encrypted password',
 'room': 'stream name'
}

message (S)

This event is used to send a message to all users inside the current client's room. The sender will also receive the message event from the server. Exemple of data sended:

{
 'content': 'formated message',
}

setTestMode (S)

This event is used to enable/disable test mode for the current client. Exemple of data sended:

{
 'value': true/false,
}

resetSocket (S)

Test mode only! This event is used to reset the client to it's default state.


Errors

400 (Syntax Error)

The received event does not follow the required format. Some mandatory properties are missing.

401 (Authentification required)

To perform the followed event, the user must be authentificated (see auth event).

403 (Unauthorized)

The user is not allowed to perfom the event.

chat_server's People

Contributors

shoko31 avatar

Watchers

James Cloos avatar  avatar  avatar Rodolphe Roussel avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.