Code Monkey home page Code Monkey logo

hipochat's Introduction

HIPOCHAT: Websocket chat server

Supports notifications and keep the old messages

Hipochat is an open-source websocket chat server, using RabbitMQ as message queue, Tornado as Backend Server and Redis for persistent data.

Keeps the notifications count and also supports injections from external server directly to websocket Supports checking authentication with your own webserver.

How it works

First clone the project

git clone https://github.com/Hipo/hipochat.git

Then install the requirements

pip install -r requirements.txt

Make sure that you have redis-server and rabbitmq servers are running Set your variables in

vars.py:

PushNotificationURL = '<ENDPOINT RECEIVES YOUR PUSH NOTIFICATION SIGNAL AND SEND AN PN>'
ProfileURL = '<ENDPOINT YOU CAN ASK IF USER IS AUTHENTICATED>'
RABBIT_URL = '<RABBITMQ SERVER>'
RABBIT_USERNAME = '<RABBITMQ USERNAME>'
RABBIT_PASS = '<RABBITMQ PASSWORD>'
REDIS_URL = '<REDIS_URL>'

You can check the nginx reverse proxy details

Technical Detail

Chat Server Endpoint

Your backend server needs an EP that you should be able to create a chat room or receive the chat room tokens

Example request:

HEADER: Authentication: Token <Token>
URLs: **/api/chat**

Example response:

{
    "chat": {
        "token": "e598c2a9-317a-4577-8cbd-7fd5f0cddbdf"
    }
}

If room is created you should receive '201 CREATED' MESSAGE else if exists '200 OK' 200 OK means you already have this chat room and you should fetch the old messages

Receive the old messages

You visit the url with parameters below

Example Request:

HEADER -> Authorization: Token <token>
HTTP GET **/talk/old/<chat_room_token>/**

Response:

HTTP 200 OK

{
oldy: [
        {
            timestamp: 1414768486.196569,
            message: "asdasda",
            author: "asdasda"
        },
        {
            timestamp: 1414770934.580683,
            message: "adsadsdasads",
            author: "assaddsa"
        },
        {
            timestamp: 1414772188.836509,
            message: "dsadasads",
            author: "dssdaasd"
        },
        {
            timestamp: 1414773038.058612,
            token: "ac9e8485-8120-4cdc-a5c7-2687a04f01b5",
            injected: {
                   message: "hede",
                   hodo: "hede"
            }
        }
      ]
}

As an authenticated user you can post injections to CHAT server

You can inject external messages from a Backend Server directly into Websocket

Example Request:

HEADER -> Authorization: Token <token>
HTTP POST **/talk/item/<chat_room_token>/**

{   message: "foobar",
    user: "johndoe"
}

Start the Live Chat Server

Chat Server works with websocket technology Also you will see the injections in chat dialogue when an injection comes directly to Chat Server You should pass the user authentication token as query parameter

Example Request:

WEBSOCKET
ws://server.url/talk/chat/<chat_token>/?token=<auth_token>

NOTIFICATIONS COUNT

You can receive the notifications count of chat rooms for authenticated user by sending a request like below

HTTP GET /talk/notification/<chat_token>/?type=<type>

Got some of the code from https://github.com/haridas/RabbitChat

hipochat's People

Contributors

ybrs avatar tunavargi avatar emre avatar

Watchers

James Cloos 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.