Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
Is there a way to get a callback acknowledgement while using adonis websockets?

I am using adonis js in my back-end and I want to get a callback acknowledgement, in the ChatController the on message function looks like this:

class ChatController {
  //{ socket, request, auth }
  constructor(ctx) {
    this.socket = ctx.socket
    this.request = ctx.request
    this.auth = ctx.auth
    // Add/Update socket id for current logged in user
    all_sockets[this.auth.user.username] = this.socket.id  
    

    this.socket.emitTo('connect', {username: this.auth.user.username, socketId: this.socket.id}, [this.socket.id])
  }

  **onMessage(message) {
    //this.socket.broadcastToAll('message', message)
    console.log('msg sent', message)
  }**

  
}

so I don't know how can I get a callback to make sure that the message was sent or not, in node js I would write it this way

socket.on('message', (msg, callback) => {
        console.log(msg);
        socket.broadcast.emit('message-broadcast', msg);
        callback({serverReceived: true})

        


        socket.emit("message-sent", (data) => {
          if(data.messageSent){
            console.log("message sent")
          }else{
            console.log("retry sending the message")
          }
        })

    });

the problem in adonis web sockets that on message is built in so I can't add another parameter for the callback, any idea how can I do it ?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!