-
Code Snippet ;p
<taken from me on Chatspot site
Here is the latest Chatspot revision note:
Changeset [178] by Techboy
I did something with the xmlhttprequest stuff - I think it's pretty clever :P The XMLHTTPRequest would always output the response to browser even if it wasnt actually a poll. So - when HTTP returns a response it has a status number at the top of the header. I used this status number to tell the library what Chatspot was returning. HTTP/1.1 999 Chatspot Poll OK :)
So, here's what the XMLHTTPRequest library code for that is:
In the file where the response is generated and returned:
Code:
****if ($_GET['action']=='poll') *
****{
*header('HTTP/1.1 999 Chatspot Poll OK');
*// Your code here
****}
In the XMLHTTPRequest Jscript:
Code:
****// We choose what we do depending on the "error" code the reqlib returns - clever huh? :> *
****if (req.status == 999) // Polling *
****{
*// What we do on a poll goes here
****}
Hope somebody finds that useful :P
-
Does it bake you waffles? no? stfu.
lol nah joking. It seems clever, but what does it really do... like in Normal english? ^__^
-
Well, in chatspot 3, whenever the server replied to you, it just echoed it to the browser, as a message.
This makes sure it only echoes messages. Without any weirdo hard to code stuff. :P