Strapi-plugin-io (IO): How to use it

Hello I want to use this pluguin for remove StrapIO . I need to do this:

I have a api for diferent restaurants. I need to connect to strapi when login in an Android app. The recieve its own orders from a pwa. So I create rooms and send the orders to the restaurant room.

I do all this with StrapIO. StrapIO is not a official plugin, so I need to change it with strapi-plugin-io.

The problem is i don’t know how use strapi-plugin-io outside the plugin configutaion i don’t know if i can do this in the order controller as i do with strapIO:

if(check_order.means == 'app'){
       const room = `room${check_order.restaurant.cp}${check_order.restaurant.id}`;
       strapi.$io.raw(room, "newOrderApp", check_order);
}

Second question is how i can create a infinite latency between strapi-plugin-io and the restaurant app, since restaurant close the app. How and Where.

Thanks i advance for your help.

Ok. We resolve this.

In the pluings.js you need to add:

    "io": {
      "enabled": true,
      "config": {
        "IOServerOptions" :{
          "cors": { "origin": "*", "methods": ["GET","POST"], credentials: true},
        },
        "contentTypes": {
          "order": ["create"],
        },       
        "events":[
          {
            "name": "connection",
            "handler": ({ strapi }, socket) => {
              strapi.log.info(`[io] new connection with id ${socket.id}`);
              socket.on('clientPing', ()=>{
                console.log("clientPing");
                setTimeout(()=> {
                  socket.emit('serverPing')}, 60000);
              })
              
              socket.on('join', function(room) {
                  socket.join(room);
              });
            },
          },
        ]
      },
    },

The you can use the strapi.$io in the controllers.

In the client you need to join to the correct room, initialice and reply (to the “serverPing”) with “clientPing”. After connection.