Socket Controller


#1

How to call event socket.broadcastToAll(“message”, “teste de mensagem”) in http controller ?

socket always return undefined


#2

Hi!

I did not understand me neither.
Basically I have defined a web socket, and for sure I can connect to it, using the following URL:

ws://localhost:3333/adonis-ws/

I have defined a channel to be bound to my WS Controller like this:

Ws.channel('job', 'JobController')

Afterwards, I tried to connect to the WS using a Chrome plugin (Simple WebSocket Client) and the only thing I can see is the echo message I’m sending to the socket, but no way to reach the controller. I think the documentation is not too much clear despite my small experience on Web Sockets.

Most likely you got undefined because of wrong WS URL. I had the same issue because I was not using the correct full URL with ‘adonis-ws’ also.