You need to request your websocket key on our website.
URL: wss://app.hyperate.io/socket/websocket?token=<MY-WEBSOCKET-KEY>
You need to join the appropiate channel before any data will be sent to your client.
To do this you need to send the following JSON message:
{
"topic": "clips:<ID>",
"event": "phx_join",
"payload": {},
"ref": 0
}
This would be the correct message to join the "internal-testing" channel:
{
"topic": "clips:internal-testing",
"event": "phx_join",
"payload": {},
"ref": 0
}
Every time the user creates a clip the following JSON will be send from the server to the client:
HINT: The twitch_slug
key in the payload
object is the slug directly from Twitch.
You would build the correct URL like this:
https://clips.twitch.tv/<twitch_slug>
Example with the slug from below:
https://clips.twitch.tv/FuriousExuberantTruffleCmonBruh-AmSuUmskamv8RPin
{
"ref": null,
"payload": {
"twitch_slug": "FuriousExuberantTruffleCmonBruh-AmSuUmskamv8RPin"
},
"topic": "clips:internal-testing",
"event": "clip:created"
}
Phoenix expects that you send the keep-alive packet every 10 seconds otherwise the connection will be closed.
{
"topic": "phoenix",
"event": "heartbeat",
"payload": {},
"ref": 0
}
In case you only want to leave a joined channel you can send the following message:
{
"topic": "clips:<ID>",
"event": "phx_leave",
"payload": {},
"ref": 0
}
This would be the correct message to leave the "internal-testing" channel:
{
"topic": "clips:internal-testing",
"event": "phx_leave",
"payload": {},
"ref": 0
}