Open wandenberg opened 12 years ago
wondering if this feature has been added? Or if I want to send messages like trade information to specific uses. Should i have them each listen to a different channel? How can I protect the chanel?(I would imagine client sends back a session id to authenticate, but can publisher be configured to call a php script?
or we use session id as channel id?
Hi,
this feature isn't implemented yet. You can connect the subscribers to a general channel to receive common messages and to a second channel to receive "private" messages, using a single connection, take a look on docs for this. About protection, the module don't care about it. Some solutions I saw being used are:
Sorry I couldn't figure the documentation:) I am guessing I can just do addChannel(public) and addChannel(private_ch) to subscribe to two channels? (underlying I am guessing you are using one long poll connection). BTW, another question, I am using pushstream.js. But the default behavior seems to not send back last message. What's the best practice here? I first make a normal http request to get, say, last 5 messages and then register listeners through pushstream.js? Thanks so much for such a great tool! I am sending my donation right awy!
never mind. figured out if i turn push_stream_store_messages on then i got the last couple of messages.
Hi,
yes, you have to set the store_messages to on and set how many old messages you want, if using stream connections, or set the seconds ago if using long polling, something like that:
//stream
pushstream = new PushStream(your_config);
pushstream.addChannel(public, {backtrack:5});
pushstream.addChannel(private_ch, {backtrack:10});
pushstream.connect();
//long polling
pushstream = new PushStream({
secondsAgo: 10,
other_options
});
pushstream.addChannel(public);
pushstream.addChannel(private_ch);
pushstream.connect();
The modes pushstream.js uses to connect can be set on the options "modes", the default is try in order, eventsource, websocket, stream and longpolling.
Add a way to publish a message to a specific user using filters, like in the example bellow.
The publish could look like /publish?Channel=B&filter=[{key=userid, val=12345}]&limit=1
Only first user matching userid=12345 on B channel would get the message.