Closed YassineChe closed 2 years ago
Hello, @YassineChe. I will make printing the logs optional Tomorrow with a new version.
Shame on me, but I didn't get the meaning of Whispers
. Do you mean Pusher's default events, like event: connection_established
?
By this 3 things I can do it as soon as possible:
Whisper
.Whisper
.Whisper
because I haven't find anything in Pusher's official docs. There are few Stack Overflow questions, but I still don't separate it from other events.@mcfugger, Thanks for quick reply, whisper event is only a client to client, for example when two users connected to the same channel you can broadcast an event
Here a snapshot for Laravel Echo. This is an example if user start typing.. You can broadcast event (client to client) that' you start typing
this.channel.listen(".sent-message", (e) => {
if (
this.conversation?.with_user?.id ==
e.from &&
this.conversation?.id ==
e.conversation_id
) {
//? Push the flow
this.conversation?.chatflows.push(e);
}
})
.listenForWhisper("typing", () => {
this.isTyping = true;
})
.listenForWhisper("stop-typing", () => {
this.isTyping = false;
});
Mobile log:
I/flutter (26648): {"event":"client-typing","channel":"private-private.message.1"}
Its successfully received in library log
But i can catch it
privateChannelEventSubscription = channel?.bind('sent-message').listen(
(event) {
// I can't catch it here
},
);
Thanks
You should bind to the whisper as if you'd bind to a separate event because method bind
filters stream of the channel and gives you all events with name sent-message
in your code. So here you bind to the whisper with name client-typing
as to a separate event of your channel:
whisperClientTypeEventSubscription = channel?.bind('client-typing').listen(
(event) {
// Catch it!
},
);
Both streams subscriptions will keep receiving their events, no worry.
As I understood from Pusher Client docs, the client side does not separate whispers from other events of a channel. So, the above code I provided should work.
Please, inform me if this could help you. I will be available tomorrow (Tuesday, August 2). I am going to have a sleep.
You should bind to the whisper as if you'd bind to a separate event because method
bind
filters stream of the channel and gives you all events with namesent-message
in your code. So here you bind to the whisper with nameclient-typing
as to a separate event of your channel:whisperClientTypeEventSubscription = channel?.bind('client-typing').listen( (event) { // Catch it! }, );
Both streams subscriptions will keep receiving their events, no worry.
@YassineChe did it help you?
Hello @mcfugger,
It worked! Thanks <3
You are welcome! I will open another issue about enabling/disabling logs. Will do it soon, today was pretty hectic.
Not a urgent! Thanks for this great Lib again
Hello, @mcfugger
Is there is anyway to listen to Whispers? Cuz i can see 'em in log but i couldn't catch 'em on 'events' !!
Log by default set to enable, and there's no such way to disable it, will be nice to add an attribute like
enableLogs: false
Thank you