Methods

Socket defines the following 3 methods: connect, disconnect, action

socket
  .connect(async (req, res) => {
    await suscribe();
    
    res.send("Connect!!!");
  })
  .disconnect(async (req, res) => {
    await unsuscribe();
    
    res.send("Disconnect!!!");
  })
  .action("message", (req, res) => {
    return "message";
  })
  .action("register", async (req, res) => {
    const user = await register(req.body);

    return user;
  })

When an action is not found it will return the following error: ActionError.

Last updated

Was this helpful?