Chatroom example

Overview

To compile and link the files set your environment in the same way as you do to build OpenAMQ server and do the following:

$ c -l im_sender.c
Compiling im_sender...
Linking im_sender...
$ c -l im_receiver.c
Compiling im_receiver...
Linking im_receiver...

To run the whole thing, you have to start OpenAMQ server first:

$ amq_server

Once the server is running you can run chatroom window this way:

$ im_receiver <broker-address> <chatroom>

For example:

$ im_receiver localhost:5672 "OpenAMQ discussion"

To send messages to the chatroom, you have to run sender window this way:

$ im_sender <broker-address> <chatroom> <your-name>

For example:

$ im_sender 127.0.0.1:5672 "OpenAMQ discussion" "Baron Bartholomaeus von Saburg-Fridetzki"

There can be any number of clients connected to the same chatroom. There's no need to create chatrooms explicitly; these are created on demand.

License

BSD

Support

  • Contact author for support.

Download

Following example uses single exchange ("amq.direct") to pass messages. Chatroom is identified by "routing key":

Following example uses separate exchanges of "fanout" type for individual chatrooms:

Comments

Add a New Comment

Edit | Files | Tags | Source | Print

rating: +2+x

Author

Martin Sustrik <moc.xitami|kirtsus#moc.xitami|kirtsus>

All examples

Simple file transfer: A simple file transfer application in C, an example of how to send and receive messages via OpenAMQ WireAPI.

Chatroom example: A simple instant messaging application in C, an example of how to send and receive messages via OpenAMQ WireAPI.