Dynamic content, I need idea

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Monica Leko

    Dynamic content, I need idea

    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:changelocat ion, id3:newuser}

    Is this ok?
  • Bart Van der Donck

    #2
    Re: Dynamic content, I need idea

    Monica Leko wrote:
    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:changelocat ion, 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,usernam e) and table 'userstatus' (userid,status)[*] . Then do...

    SELECT user.username, userstatus.stat us
    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[i]) document.write( user[i]+': '+status[i]+'<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,statusi d).
    [**] No data for status['2'].

    Hope this helps,

    --
    Bart

    Comment

    Working...