Multicastr: A |
⚠️ 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 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.
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.
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.
Press Shift+Enter to create a new line
Press Enter to send the message