Node.js Faye

84 views
Skip to first unread message

Микола Патько

unread,
Nov 14, 2014, 4:35:06 PM11/14/14
to nod...@googlegroups.com
Hi, I use faye (Node.js) for creation messaging.
How do I get all messages from the channel?
When user enters, that he could see all messages from the channel

Jim Tittsler

unread,
Nov 14, 2014, 7:34:00 PM11/14/14
to nod...@googlegroups.com
On Sat, Nov 15, 2014 at 6:35 AM, Микола Патько
<mykola.f...@gmail.com> wrote:
> How do I get all messages from the channel?
> When user enters, that he could see all messages from the channel

The user's client can subscribe to the channel, with a specified
function being invoked for each new message sent to that channel:

subs[i] = client.subscribe('/WEnotes/theChannel', function(msg) {
newPost(i, msg);
});

If you mean receive messages sent to the channel before he connected,
that is outside the scope of Faye. You will need to implement another
mechanism for retrieving the historical messages. (I use CouchDB with
views that copy my channels.)

Микола Патько

unread,
Nov 15, 2014, 2:37:06 AM11/15/14
to nod...@googlegroups.com
Can you give me the example of code CouchDB with retrieving the historical messages ??? Or info links?

Субота, 15 листопада 2014 р. 02:34:00 UTC+2 користувач Jim Tittsler написав:

Jim Tittsler

unread,
Nov 15, 2014, 7:46:05 PM11/15/14
to nod...@googlegroups.com
On Sat, Nov 15, 2014 at 4:37 PM, Микола Патько
<mykola.f...@gmail.com> wrote:
> Can you give me the example of code CouchDB with retrieving the historical
> messages ??? Or info links?

You could store the messages anywhere and allow the clients to
retrieve them (or play them back on connection).

I only mentioned CouchDB as one possible solution since its append
only style fits well with the history of messages. WikiEducator's
WEnotes client is built on this scheme.
https://gitorious.org/wikieducator/wenotes/source/e7a7bdc3b5d535a44630b58cc49e6203ad071d63:WEnotes.js#L466
Reply all
Reply to author
Forward
0 new messages