dhiegorp / multicastr

An example of chat application using RabbitMQ via STOMP protocol

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rabbitmq logo

Multicastr: A not so good implementation of a chat app with RabbitMQ

⚠️ Disclaimer: This code was not implemented with security in mind or any intention to be production-ready code. This is just an example, use it as an introduction to your studies.

Multicastr


Multicastr is a simple chat client application built on Javascript/HTML5/CSS, using a message broker as backend.

The communication between the message broker and the client is relied upon the Simple/Streaming Text Oriented Messaging Protocol, STOMP over WebSockets, implemented by the StompJs library.

To simplify the process, every active client -- a browser window/tab -- receives an UUID as its identification, not allowing the user to input a nickname.

Installation


For the frontend you just need to download or clone the project - you can run it in your browser. For the backend you`ll have to have the RabbitMQ installed and configured.

Configuring RabbitMQ to run Multicastr

After installing RabbitMQ you have to enable the Web STOMP plugin. To to this, execute the following line

rabbitmq-plugins enable rabbitmq_web_stomp

In this example I also configured a new virtual host and set permitions to the guest user. To do this, run

rabbitmqctl add_vhost multicastr

and

rabbitmqctl set_permissions -p mmulticastr guest ".*" ".*" ".*"

Another step is to configure a funout exchange named ChatExchange. You can rename it for your own configuration if you want editing the comm.js file, setting the const EXCHANGE:

//const EXCHANGE = '/exchange/ChatExchange';
const EXCHANGE = '/exchange/YourFunoutExchange'

You don`t need to create any queues, everytime a STOMP client connects to RabbitMQ and subscribe to an exchange, it creates its own temporary queue by default, and bound it to the given exchange.

Frontend

On the textarea input:

Press Shift+Enter to create a new line
Press Enter to send the message

Screen samples


First user screen, same "room" first client interface

Second user screen, same "room" second client interface

About

An example of chat application using RabbitMQ via STOMP protocol


Languages

Language:JavaScript 47.5%Language:CSS 37.2%Language:HTML 15.3%