Table of Contents

XMPP Chat

To support scalable text/audio/video chat through XMPP. Chat will be focused towards a taks(review or feedback).

Design

1. Each and every user is registered against an xmpp server when a user is created and his account does not exist already in the server.

2. Once a user opens a page he is connected to the xmpp server and the users with whom he can chat will have the chat related icons enabled.

3. Chats are context specific.

Screen designs

1. Chat (on the same page)

Manager initiates: http://invis.io/VQ38BE8XU

Employee replies:http://invis.io/R338BFQ5V

2. Chat (on a different page)

Manager initiates: http://invis.io/DR38BGIUG

Employee replies: http://invis.io/Y238C6XWS

Implementation

Following are used for the implementation.

1. https://www.ejabberd.im/ - XMPP server with BOSH support

2. https://github.com/sstrigler/JSJaC/ - XMPP JS client.

3. https://xmpp4r.github.io/ - XMPP ruby client

4. https://github.com/valeriansaliou/giggle - XMPP jingle library which is used for audio/video chats.

Other libraries/alternatives explored

1. https://www.jsxc.org/

2. http://strophe.im/strophejs/

3. https://github.com/estos/strophe.jingle

To be done

1. Grouping chats by task and notifications.

2. Saving chat history.

Database Changes

Table Name: users (Following columns are added)

Column Name Type Description
xmpp_login String xmpp login
encrypted_xmpp_password String encrypted xmpp password

Setting up chat

Setup ejabberd

1. Download and install ejabberd (15.04 or above) https://www.process-one.net/en/ejabberd/downloads

2. while setting up, please give a hostname (ex - mylocal.com). This needs to be noted down.

3. Change the config settings. Config file can be found in your ejabberd directory under conf (ex - /opt/ejabberd-15.04/conf/ejabberd.yml)

Change “register:” (around line 481)

  register: 
    all: allow
    registration_timeout: infinity

Change “registration_timeout:” (around line 494)

registration_timeout: infinity //(yaml file level)

Enable “mod_ping”

mod_ping:
    send_pings: true
    ping_interval: 250
    timeout_action: none

3. Start/Restart ejabberd

4. Create a shared roster for every one.

Screenshot with information

5. Add a host entry for the IP pointing to the URL.

Configuring chat server

1. Configure the settings in config/chat.yml and enable chat. Sample settings for development environment look like below.

development:
  server: http://192.168.2.118:5280
  bosh: http://192.168.2.118:5280/http-bind
  websocket: ws://192.168.2.118:5280/websocket
  domain: mylocal.com 
  enabled: true
  create_xmpp_user: true

2. Create xmpp_login for existing users and populate thread id for older review assignments.

rake backfill:create_xmpp_account_for_users

rake backfill:populate_chat_thread_id_in_review_assignment