Not able to use Room model inside chatcontroller

const Ws = use(‘Ws’)
const Room = use(“App/Models/Room”)

class ChatController {
constructor ({ socket, request,auth }) {
this.socket = socket
this.request = request
this.auth = auth
}

// broadcastToAll(‘message’, message)
onMessage (message) {
const id = this.auth.user.id;
console.log(id);
const topic = Ws.getChannel(this.socket.topic).topic(this.socket.topic);

if(topic){
  topic.broadcast('message',message);
 }

}
}

await and yield are also not running inside the ws controller

Await works only in async functions.

If you want to run it you have to make some function async and use await in there

1 Like