ajaxim chat - help

Discussion in 'JavaScript' started by morkov4o, Jan 11, 2009.

  1. #1
    Hi people! I downloaded the chat script ajaxim from ajaxim.com. I like the script but there is something what i don`t like. When i push F5 (refresing web page) the script alert me, that i must login again with the password and user. I don`t like this. Can someone help me to change this? I think that the script destroy the session when i push refresh. I need to make this, because i want to integrate the script in my site with da same tables and other. I don`t need help for integrate but this refresh is ... the BIG PROBLEM!

    Regards Vlado!
     
    morkov4o, Jan 11, 2009 IP
  2. morkov4o

    morkov4o Peon

    Messages:
    34
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Somebody can help me? :)
     
    morkov4o, Jan 12, 2009 IP
  3. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #3
    erm, hi vlado :D

    how about--you don't press refresh? i know, obvious and all that...

    it is stupid and naive to expect that pages rendered as a result of POST submissions (or those that use ajax via credentials to fetch data dynamically/login) can survive a reload. that's like saying, i don't like what happens when i crash my car, i have to spend ages stuffing the air bags back in. don't crash the car?

    yes, there are instances where a reload won't matter much - if the connection is local and not via ajax, you should be able to retain your credentials and session data. i don't think so in this instance - although i bet you can script an auto-login that resubmits/performs for you.

    incidentally, if you think you cannot help yourself, you can prevent F5 from functioning or intercept it and do something before the key's real event takes place. it would probably make sense to migrate the contents of the iframe or layer into a popup window where it can survive your reload - but its just too quirky to be worth it and nothing can stop the user from clicking on the reload button itself as opposed to using F5.
     
    dimitar christoff, Jan 12, 2009 IP
  4. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #4
    also, i had a look at the source, this chat is written rather badly from a network point of view.

    data arrives back as JSON like so...

    {"events":[{"event":"status,2","sender":"test","recipient":"test","group":"Friends"}]}

    {"messages":[{"message":"<span style=\"font-family:12,sans-serif;font-size:rgb(0, 0, 0)px;color:undefined
    ;\">(Auto-Reply) I'm busy<\/span>","sender":"test","recipient":"test","chatroom":0}]}

    however, it seems to use POST ajax requests to query the IM 'world' server status every 3 seconds and the POST data adds a lot of lag and overhead as opposed to what GET can achieve for this. this is also the reason why you find yourself needing to refresh your chat every now and then - accumulative lag over periodical POST requests can cause dropped messages which in turn can cause js errors and collapse your timeline...
     
    dimitar christoff, Jan 12, 2009 IP
  5. morkov4o

    morkov4o Peon

    Messages:
    34
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi! 10x for your reply! I don`t have lag, but i have a habit to refresh the web page using F5 (professional habit). Now i read the sorce code and i see, that the request are with POST. I don`t have lag but when i refresh the page i brake all sessions and other. Ok! But is it way to integrate ajaxIM with my site. EXAMPLE: users table - one for the chat and for the site. When i login to my site ... and press botton login to the chat i don`t wanna see message alert for login. Maybe when the session vars are same ?
     
    morkov4o, Jan 12, 2009 IP
  6. morkov4o

    morkov4o Peon

    Messages:
    34
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I try and i make it :p :))) 10x
     
    morkov4o, Jan 12, 2009 IP
  7. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #7
    you should be able to submit a username and password and callup their target direct, i would have thought...
     
    dimitar christoff, Jan 12, 2009 IP