I'm a bit confused on the presence-channels
in Pusher's platform, as I'm building a chat application from scratch. Now, I know some of you guys have seen tons of "realtime chat app" topics around, but, I'm looking for a peer-to-peer chat and not the site-wide global thingy. More like a facebook chat, where you can go one-to-one.
Now, I've seen an example in PubNub's demos (named Babel) but, that thing is far from what I'm looking for because I've checked the requests in the console and even if it's not shown, the sent messages between other users are shown in my network request logs too because it's being filtered in JS and not server-side and thats not something I want for sure.
So, coming back to the subject, I'm aware of the channel / private-channel / presence channel functionality, and I decided to do this:
When opening the app, every user subcribes to his
private-user_id
channel ( creates, if it doesn't exist already ).At the same time ( while opening the app )
user1
subscribes to apresence-global
channel where others keep track if friends are online.When others want to send him a message, e.g.
user2
touser1
, he subscribes toprivate-1
thereafter javascript will process the events.
Now, I know something's wrong with this because.. if user3
would send a message to user1
he'd subscribe to private-user1
so I guess he'll see the events that user2
is triggering when sending messages to user1
too, right ? Or did I get this wrong ?
I've read in their docs that presence
channel is actually a private
channel extension, so I'm thinking now.. why using private
channels anymore, and then, how can I notify all my friends I'm online.
But then, something else comes up in their docs , telling me that channels
provide two important things (among others), from which, first is a way of filtering data
and second is a way of controlling access
.
How am I supposed to "filter data" since there's no link in their docs, or better, what do you have in mind for a one-to-one chat. I'm sorry if I got all their docs wrong, I had a look on their sample applications but none of them are using the one-to-one technique which I'm looking for.
I am new to Pusher and socket connections etc, but I've learned how to authenticate, how to create , detect and process the events in the channel, and I can create a simple global chat with online members, but, when it comes to private-channels I'm quite confused on how to create separate channels for two users.
Thanks in advance !