Download Luar/moonloader/lib/examples/websocket_client.lua from andy-gg/LUAR_RP_PC: direct link, hf CLI and curl.
- Browser
- Download file 537 Bytes
-
https://huggingface.co/datasets/andy-gg/LUAR_RP_PC/resolve/main/Luar/moonloader/lib/examples/websocket_client.lua
- Command line
-
hf download hf://datasets/andy-gg/LUAR_RP_PC/Luar/moonloader/lib/examples/websocket_client.lua
-
curl -L -o websocket_client.lua https://huggingface.co/datasets/andy-gg/LUAR_RP_PC/resolve/main/Luar/moonloader/lib/examples/websocket_client.lua
537 Bytes
| #!/usr/bin/env lua | |
| --[[ | |
| Example of websocket client usage | |
| - Connects to the gdax market data feed. | |
| Documentation of feed: https://docs.gdax.com/#websocket-feed | |
| - Sends a subscribe message | |
| - Prints off 5 messages | |
| - Close the socket and clean up. | |
| ]] | |
| local websocket = require "http.websocket" | |
| local ws = websocket.new_from_uri("wss://ws-feed.gdax.com") | |
| assert(ws:connect()) | |
| assert(ws:send([[{"type": "subscribe", "product_id": "BTC-USD"}]])) | |
| for _=1, 5 do | |
| local data = assert(ws:receive()) | |
| print(data) | |
| end | |
| assert(ws:close()) | |