Closed nicitaacom closed 7 months ago
Also I have question is it possible to fire event only in 1 channel?
When you call trigger the event will be fired to all channels, including the data. You can see the docs for triggering events with Node at https://github.com/pusher/pusher-http-node?tab=readme-ov-file#publishing-events.
The page you link to details how to bind to event, and how to trigger client events which are a special type of event that originate at the client.
When you call trigger the event will be fired to all channels, including the data.
Yes but I see different - that right now it fires only to channel I passed as first prop evidence that event will be trigerred only for channel passed in frist prop https://streamable.com/tubzc8
When you call trigger the event will be fired to all channels, including the data
You 100% messege me some wrong data
Otherwise why do I need this?
Anyway event "be fired to all channels" - why do I need string [] in this case? (or even channelId if event will be fired to all channels)
The item you underline shows that you can either pass a single channel (channel: string
) or you can pass an array of channels (string[]
). I had assumed it was implicit, so apologies and I will rephrase:
When you call trigger the event will be fired to all specified channels, including the data
The item you underline shows that you can either pass a single channel (
channel: string
) or you can pass an array of channels (string[]
). I had assumed it was implicit, so apologies and I will rephrase: When you call trigger the event will be fired to all specified channels, including the data
https://github.com/pusher/docs/assets/39565703/68da77c3-a30b-4d08-813b-b414de225a8b
When you call trigger the event will be fired to all specified channels, including the data
So why in this case channel 'tickets' triggered as well?
If you need minimal example I ready to create it in case you dig deeper into this problem
Can you show what is happening in the Pusher debug console, or add some logging to your app? It isn't easy to figure out precisely what is happening, but a cursory test of the node library shows that triggering to a single channel does not trigger any events on any other channels.
Can you show what is happening in the Pusher debug console, or add some logging to your app? Yes I can
How do you find to create some appointment and you tell me why I work like so I'd like to discuss it in discord
We aren't able to meet to discuss this, although we do offer this as part of our paid support plans. If you are able to respond to the outstanding queries we can progress this here.
I mentioned a test on the Node library. This is the code I used:
const Pusher = require("pusher");
const pusher = new Pusher({
appId: 'NNN',
key: 'NNN',
secret: 'NNN',
cluster: 'NNN'
});
pusher.trigger("private-channel", "my-event", {
message: "hello world"
}).then(response => {
console.log(`message sent, ${response.statusText}` )
}).catch(e => {
console.log(e)
});
And this is how the event shows in the Pusher debug console
This doesn't appear to be a library issue but possibly an implementation issue with the wrong/unexpected route being used to publish the event, which is causing the event to be triggered to multiple channels.
This is the code I used:
You don't subscribe pusher to some channel (I have 2) aslo you use it in 1 file - its nor real example (I mean it some ideal conditions to make it work)
code I use to reproduce it
api/tickets/close
await pusherServer.trigger(ticketId, "tickets:closeByUser", null)
DesktopSidebar.tsx
useEffect(() => {
pusherClient.subscribe("tickets")
const closeByUserHandler = (ticket: ITicket) => {
router.push("/support/tickets")
// hide completed ticket
setTickets(current => {
return [...current.filter(tckt => tckt.owner_id !== ticket.owner_id)]
})
// show toast
toast.show(
"success",
"User closed ticket",
"You may check your stats here - TOTO - create support/statistic page",
6000,
)
}
const closeBySupportHandler = (ticket: ITicket) => {
router.push("/support/tickets")
// hide completed ticket
setTickets(current => {
return [...current.filter(tckt => tckt.owner_id !== ticket.owner_id)]
})
}
pusherClient.bind("tickets:closeBySupport", closeBySupportHandler) // router.push('support/tickets') and filter
pusherClient.bind("tickets:closeByUser", closeByUserHandler) // router.push('support/tickets') and filter and toast
return () => {
pusherClient.unbind("tickets:closeBySupport", closeBySupportHandler)
}
SupportButton.tsx
useEffect(() => {
pusherClient.subscribe(userId) // ticketId = userId
const closeHandler = () => {
setMessages([])
}
pusherClient.bind("tickets:closeBySupport", closeHandler)
pusherClient.bind("tickets:closeByUser", closeHandler)
return () => {
pusherClient.unbind("tickets:closeBySupport", closeHandler)
pusherClient.unbind("tickets:closeByUser", closeHandler)
},[])
In DesktopSidebar.tsx when you trigger this code
await pusherServer.trigger(ticketId, "tickets:closeByUser", null)
it trigger event
Subscribing to a channel in the client does not change the behaviour of the triggering code. You can trigger events to any channel, regardless of what the clients are subscribed to (or not subscribed to), the triggering code has no knowledge or context of what is happening on the client.
My replication was invoking the same trigger
method you are invoking and it shows that when this is invoked only a single event is sent.
If you can provide some replication steps for me to follow then I can investigate. Invoking 'pusherServer.trigger(ticketId, "tickets:closeByUser", null)` as you have doesn't replicate the issue and this is why I have mentioned that it appears to be an issue with the wider implementation.
I forgot about this issue I fixed it somehow
I'm still think that its bug I argree that it might be mistake in my code cause I didn't created minimal reproduction
Hello there, I spotted an issue on https://pusher.com/docs/channels/using_channels/events/
Here should be written that event will be fired in all channels but data will be passed only in channels in first prop By first prop I mean this