Skip to content

Socket IO

Gustaf Järgren edited this page Jan 7, 2020 · 2 revisions

Socket IO API

Connect to backend

Setup a Socket.IO 2.+ Websocket to wss://smapi.gorymoon.se/v2. You should retry to reconnect to the backend if the connection is lost, some work can be done and the backend can be restarted (won't be common that it restarts).

The API needs a token that the streamer provides with the token query parameter (specifics on how to depends on the library you use)

You can either send the game you are connecting with as a query parameter or send it while you are connected. When sending the game id the extension becomes active to the viewer, depending on your setup and game you can send the game id when it is appropriate.

An example of a C# implementation can be found here and here.

Query Params Type Required
token String Yes
game String No

Connected

If you sending the game as a query parameter you need to send it to the game event with the id of the game as the parameter. Sending an empty string will deactivate the extension.

You will receive action events on action and channel point events on cp_action (if you want to use this channel point system)

Events From Data
game Game String, ex. 'spaceengineers'
action API JSON, example below
cp_action API JSON, example below

Action examples

{
   "bits":"1",
   "user":"bits user",
   "action":"disable_thrusters",
   "settings":{
      "message":"In-game message..."
   }
}
{
   "bits":"1",
   "user":"bits user",
   "action":"give_item",
   "settings":{
      "items":[
         {
            "id":"Ore/Stone",
            "amount":"1000"
         },
         {
            "id":"Ore/Iron",
            "amount":"100"
         }
      ]
   }
}

Channel Point Action

{
  "user": "twitch user",
  "id": "e6149787-6bcc-4bbc-bdd9-c360de68c956"
}

Clone this wiki locally