Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel echo Whisper()/listenForWhisper() #9

Open
nielsezeka opened this issue May 29, 2019 · 1 comment
Open

Laravel echo Whisper()/listenForWhisper() #9

nielsezeka opened this issue May 29, 2019 · 1 comment

Comments

@nielsezeka
Copy link

nielsezeka commented May 29, 2019

I follow the docs that lead me to :"See full Echo documentation for all available methods"
So the Echo documentation i want to use the broadcast in room by using Whisper function.
I checked and it completely existed in code. But when i try to broadcast by:

guard let channelEmit = channel as? IPrivateChannel else{ return }
channelEmit.whisper(eventName: "xxxx", data: [])

Actually packet was emit to the server as the socketio log recorded. So i can make sure this function called and it actually send some data to server.
But the problems is their is nothing received in another client(s) when i try to using listening code:
_ = channel!.listenForWhisper(event: "xxxx", callback: { (data, ack) in
print("received")
})

So could you please help me on this problem? This repo support broadcast as Echo documentation describe?

@nielsezeka
Copy link
Author

I found problems,
1- we need to set the broadcast channel name same with backend setting(their was an configuration about formatting name in server-side). In my case the name must be format "channel.xx" with "xx" is an int number(ex: "channel.1", "channel.2".....).
2- Another problem is: we need to listen by listen(event....)(i dont know why the listenForWhisper(..) not work). The event comes to you with format: "client-xxxx" with xxxx is your sending name.
For your refer, my working code is:
** channel = self.echoLaravel.privateChannel(channel: "channel.1")**

To send:
guard let channelEmit = channel as? IPrivateChannel else{ return }
channelEmit.whisper(eventName: "xxxx", data: [])

To received
_ = privateChannel.listen(event: "client-xxx", callback: { data, ack in
.....
})

Hope these information helpful!

@nielsezeka nielsezeka mentioned this issue May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant