You could for example make the usernames the key of the array.
var userlist = [];
userlist["username1"] = userobject;
userlist["username2"] = userobject;
And then you can easily check if someone exists by doing something like:
if (userlist["username1"]) {
console.log("user online!");
} else {
console.log("user offline!");
}
But, you will need to make sure that the users will get kicked of the userlist
when they go offline, which if perfectly possible using Ape Server functions.
Good luck!
----- Original Message -----
From: J99
To: [email protected]
Sent: Monday, January 07, 2013 1:03 PM
Subject: [APE Project] Can I check if a user is online (by nickname)?
I am developing a private chat (more like IM) with php+mysql backend that
keeps track of who talks with whom etc. There may be many users online (a few
1000) and I don't want users to download a whole userlist everytime they reload
a page. Also I know that user has e.g. 5 threads opened so I want to check only
for these 5 users if they are online and get their pipe ID. Every user also has
his own profile page where I want to show a badge if he's online or not.
My current version works is made so that when user connects to APE server he
gets a whole userlist of currently connected users and then I have to do
foreach and search only for a single (or a few) users from that list that I
need... I don't think this is the best way, especially when number of online
users grows.. So I am looking for a solution how to make a webservice or smth
that will enable me to check for each user by username if he's online and get
his pipe ID.
Is this possible? How can it be done?
I am new to APE and I did only front-end development, the backend was left
intact but I guess that what I need is something that I will have to do on
backend, am I right?
thank you!
--
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/
Geen virus gevonden in dit bericht.
Gecontroleerd door AVG - www.avg.com
Versie: 2013.0.2805 / Virusdatabase: 2637/6016 - datum van uitgifte: 01/07/13
--
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/