Hi,

I guess every user in your database have a list of friends with their "id".
The easiest way for you would be to pass two parameters when you connect to
APE, this way :
{ id: #userId, friends: [#idFriend1, #idFriend2 ... ], otherParams... }
in Ape, you would then use
user.setProperty('id', params.id);
and
user.friends = friends;
(I don't use setProperty for json and arrays since it proven to return
strange values with getProperty at the beginning, I didn't test in latest
versions though).
Then... all you users should join a channel named "general" or... anything.

This function could be usefull :
function in_array(item, array) {
    for(var i = 0; i < array.length; i++) {
        if(array[i] == item) return true;
    }
    return false;
}

To send a message to all your friends, you would then have to parse this
userlist.

var chan = Ape.getChannelByName('general');
chan.userslist.each(function(user) {
    if(in_array(user.getProperty('id'), info.user.friends)) {
        user.pipe.sendRaw('message', { from: info.user.getProperty('id'),
content: params.message });
    }
});

This way, users will only receive your message if they belong to your
friends list.
I assumed that you would use params and info as parameters of the callback
function binded to your message command.

Regards, Julien.

2011/6/7 RonnieV <[email protected]>

> Hi,
>
> First of all, I know that APE doesn't deal with users that are
> registered on your site.
>
> What I want is when I send a message to the ape server only my friends
> get notified, currently I am using inlinepush but when a message has
> been send every body get's notified. At this moment I filter my
> friends with client side javascript en only notify them, but if you
> have something like firebug you can see the message even if you are
> not my friend on my site.
>
> What should i do to create a system like mentioned above? should I
> send all of my friends userid's with the request and give every user a
> specific channel? for instance there userid? and then send the
> messages only to the channels that are given as a userid?.
>
>
> Hope someone can answer my question
>
> Regards, Ronnie
>
> --
> You received this message because you are subscribed to the Google
> Groups "APE Project" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/ape-project?hl=en
> ---
> APE Project (Ajax Push Engine)
> Official website : http://www.ape-project.org/
> Git Hub : http://github.com/APE-Project/
>

-- 
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/

Reply via email to