More info in the comment

This commit is contained in:
King_DuckZ 2022-05-14 08:06:38 +02:00
parent a0cfc10fa2
commit ccd15301af
3 changed files with 11 additions and 0 deletions

View file

@ -1,3 +1,6 @@
### communication with wss://bitcoinity.org/webs_bridge/websocket ###
```
SEND >> {"topic":"all","event":"phx_join","payload":{},"ref":"1"} SEND >> {"topic":"all","event":"phx_join","payload":{},"ref":"1"}
RECV << {"event":"phx_reply","payload":{"response":{},"status":"ok"},"ref":"1","topic":"all"} RECV << {"event":"phx_reply","payload":{"response":{},"status":"ok"},"ref":"1","topic":"all"}
SEND >> {"topic":"webs:markets","event":"phx_join","payload":{},"ref":"2"} SEND >> {"topic":"webs:markets","event":"phx_join","payload":{},"ref":"2"}
@ -5,11 +8,13 @@ RECV << {"event":"phx_reply","payload":{"response":{},"status":"ok"},"ref":"2","
SEND >> {"topic":"webs:markets_kraken_USD","event":"phx_join","payload":{},"ref":"3"} SEND >> {"topic":"webs:markets_kraken_USD","event":"phx_join","payload":{},"ref":"3"}
RECV << {"event":"phx_reply","payload":{"response":{},"status":"ok"},"ref":"3","topic":"webs:markets_kraken_USD"} RECV << {"event":"phx_reply","payload":{"response":{},"status":"ok"},"ref":"3","topic":"webs:markets_kraken_USD"}
RECV << {"event":"new_msg","payload":{"data":{"currency":"USD","exchange_name":"bitfinex","last":29420.94784483}},"ref":null,"topic":"webs:markets"} RECV << {"event":"new_msg","payload":{"data":{"currency":"USD","exchange_name":"bitfinex","last":29420.94784483}},"ref":null,"topic":"webs:markets"}
```
--- ---
```
SEND >> {"topic":"all","event":"phx_join","payload":{},"ref":"1"} SEND >> {"topic":"all","event":"phx_join","payload":{},"ref":"1"}
RECV << {"event":"phx_reply","payload":{"response":{},"status":"ok"},"ref":"1","topic":"all"} RECV << {"event":"phx_reply","payload":{"response":{},"status":"ok"},"ref":"1","topic":"all"}
SEND >> {"topic":"webs:markets","event":"phx_join","payload":{},"ref":"2"} SEND >> {"topic":"webs:markets","event":"phx_join","payload":{},"ref":"2"}
@ -18,3 +23,4 @@ SEND >> {"topic":"webs:markets_kraken_USD","event":"phx_join","payload":{},"ref"
RECV << {"event":"phx_reply","payload":{"response":{},"status":"ok"},"ref":"3","topic":"webs:markets_kraken_USD"} RECV << {"event":"phx_reply","payload":{"response":{},"status":"ok"},"ref":"3","topic":"webs:markets_kraken_USD"}
RECV << {"event":"new_msg","payload":{"data":{"connected_count":1355}},"ref":null,"topic":"webs:markets"} RECV << {"event":"new_msg","payload":{"data":{"connected_count":1355}},"ref":null,"topic":"webs:markets"}
RECV << {"event":"new_msg","payload":{"data":{"currency":"EUR","exchange_name":"paymium","last":28363.44}},"ref":null,"topic":"webs:markets"} RECV << {"event":"new_msg","payload":{"data":{"currency":"EUR","exchange_name":"paymium","last":28363.44}},"ref":null,"topic":"webs:markets"}
```

View file

@ -76,6 +76,11 @@ namespace {
//out the websocket address and the correct sequence of messages to //out the websocket address and the correct sequence of messages to
//initiate the communication properly. //initiate the communication properly.
//https://github.com/terrablue //https://github.com/terrablue
//1) {"topic":"all","event":"phx_join","payload":{},"ref":"1"}
//2) {"topic":"webs:markets","event":"phx_join","payload":{},"ref":"2"}
//3) {"topic":"webs:markets_bitfinex_USD","event":"phx_join","payload":{},"ref":"3"}
//See docs/bitcoinity/sample_communication.md for a real world example
{ {
ws.write(R"({"topic":"all","event":"phx_join","payload":{},"ref":"1"})"); ws.write(R"({"topic":"all","event":"phx_join","payload":{},"ref":"1"})");
auto resp = to_bitcoinity_message(ws.read()); auto resp = to_bitcoinity_message(ws.read());