Dynamic content, I need idea

M

Monica Leko

Hi

I have small site which will track users talking on mobile phone (site
will refresh every x minutes and retreive new data from the server).
Users can change their location (walking), or they can talk standing
at same place. If they are walking then they are moving on the site,
two. User can be remove from site, and new users can be added to the
site. What is the common pattern for this kind of problems? Should I
use dictionaries, one which will track existing users on site, and one
which will contain data from server, and then I compare data from
server and existing data. For example

If I have {id1:user1, id2:user2} ang get from server {id1:remove,
id2:changelocation, id3:newuser}

Is this ok?
 
B

Bart Van der Donck

Monica said:
I have small site which will track users talking on mobile phone (site
will refresh every x minutes and retreive new data from the server).
Users can change their location (walking), or they can talk standing
at same place. If they are walking then they are moving on the site,
two. User can be remove from site, and new users can be added to the
site. What is the common pattern for this kind of problems? Should I
use dictionaries, one which will track existing users on site, and one
which will contain data from server, and then I compare data from
server and existing data. For example

If I have {id1:user1, id2:user2} ang get from server {id1:remove,
id2:changelocation, id3:newuser}

Is this ok?

I don't fully understand how you get the {id1:user1, id2:user2...}
when it doesn't originate from the server. To me it would look as a
typical server-side stored user-table.

The kind of data relation is that of a SQL join-command, in your case
table 'user' (userid,username) and table 'userstatus' (userid,status)
[*] . Then do...

SELECT user.username, userstatus.status
FROM user, status
WHERE user.userid = username.userid

....to get the list of current statuses of the users that are present
in 'userstatus'.

If you don't do it in SQL, I think dictionary lookups are the most
common approach. The server script could for example print out the
variables to javascript and join them as follows:

var user = new Object();
user['1'] = 'John';
user['2'] = 'Fritz';
user['3'] = 'Peter';

var status = new Object();
status['1'] = 'newuser';
status['3'] = 'remove'; // [**]

for (var i in user) {
if (status) document.write(user+': '+status+'<br>');
}

If the refresh ratio is several minutes, I would indeed opt for a
simple page reload in stead of XMLHttpRequest or iframe techniques.

[*] Most would probably prefer a third table 'status' (statusid,
statusname) and change table 'userstatus' into (userid,statusid).
[**] No data for status['2'].

Hope this helps,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top