| 1 |
This example demonstrates a simple chat with manual paginated message recovery from a history stream. |
| 2 |
|
| 3 |
**This example does not cover all edge cases** (error handling, handling disconnects while recovery in process left as an exercise for a user) - it mostly shows the use of API to iterate over history from client side. |
| 4 |
|
| 5 |
Client subscribes on a channel, on first subscribe we save a channel current stream position to a variable, then on reconnect (which is artificially initiated by a server) we try to restore messages from server history – we do this in chunks calling `history` method with `since` and `limit` filter params. |
| 6 |
|
| 7 |
To start example run the following command from example directory: |
| 8 |
|
| 9 |
``` |
| 10 |
go run main.go |
| 11 |
``` |
| 12 |
|
| 13 |
Then go to http://localhost:8000 to see it in action. |