| 1 |
This example shows how to use custom Broker implementation based on [Nats](https://nats.io/) messaging server. Here Nats handles PUB/SUB stuff while presence information managed by Redis. |
| 2 |
|
| 3 |
Nats Broker does not support any methods related to publication history – it only provides at most once PUB/SUB. |
| 4 |
|
| 5 |
Start Nats server locally: |
| 6 |
|
| 7 |
``` |
| 8 |
go get github.com/nats-io/nats-server |
| 9 |
nats-server |
| 10 |
``` |
| 11 |
|
| 12 |
Start Redis (for handling presence): |
| 13 |
|
| 14 |
``` |
| 15 |
redis-server |
| 16 |
``` |
| 17 |
|
| 18 |
Finally, to start example run the following command from example directory: |
| 19 |
|
| 20 |
``` |
| 21 |
go run main.go |
| 22 |
``` |
| 23 |
|
| 24 |
Go to http://localhost:8000. You will see simple chat app, try writing a chat message in one browser tab and you should see it appears in another tab. |