laravel-echo-ios icon indicating copy to clipboard operation
laravel-echo-ios copied to clipboard

Can ' t get data from channel.listen callBack

Open codeCarbConoisseur opened this issue 5 years ago • 4 comments

I' m creating an Echo instance with params then a add echo.connected( callback: { (data, ack) in print("connected") let channel = self.echo.privateChannel(channel: "myChannel" channel.listen(event: "ChatMessage") { (data,ack) in print(data) } }) I successfully have logs that I m connected to channel and subscribed to my "ChatMessage" event, and also I receive messages from my chat(in Logs), but i can't get data from callback! idk why , but it s not working! plz help me! the code doesn't go inside the callback, I checked with debugger

codeCarbConoisseur avatar Aug 12 '20 14:08 codeCarbConoisseur

I' m creating an Echo instance with params then a add echo.connected( callback: { (data, ack) in print("connected") let channel = self.echo.privateChannel(channel: "myChannel" channel.listen(event: "ChatMessage") { (data,ack) in print(data) } }) I successfully have logs that I m connected to channel and subscribed to my "ChatMessage" event, and also I receive messages from my chat(in Logs), but i can't get data from callback! idk why , but it s not working! plz help me! the code doesn't go inside the callback, I checked with debugger

i get the same issue . if you resolved . Please share solution with me Thank you so much.

thuanuit96 avatar Aug 14 '20 04:08 thuanuit96

I' m creating an Echo instance with params then a add echo.connected( callback: { (data, ack) in print("connected") let channel = self.echo.privateChannel(channel: "myChannel" channel.listen(event: "ChatMessage") { (data,ack) in print(data) } }) I successfully have logs that I m connected to channel and subscribed to my "ChatMessage" event, and also I receive messages from my chat(in Logs), but i can't get data from callback! idk why , but it s not working! plz help me! the code doesn't go inside the callback, I checked with debugger

When you instantiate Echo client you should obviously set some namespace. For example: let e : Echo = Echo(options: ["host":"http://localhost:6001", "auth": ["headers": ["Authorization": "Bearer " + token]], "namespace": "App//Events" ])

rutim7 avatar Aug 25 '20 18:08 rutim7

Same here, adding namespace not helping, I see in logs that room connected, events are Handling in Logs, but callback of .listen doesn't firing...

Update: Yeah for me after all was naming issue, eventFormatter from lib, was formatting a bit wrongly for my case, so if you have some problems with this look into eventFormatter inside lib!

thekingofsofa avatar Oct 08 '20 10:10 thekingofsofa

Change namespace like @rutim7 will work fine . Thank you so much .

thuanuit96 avatar Oct 19 '20 11:10 thuanuit96