• Lucid Dreaming - Dream Views




    Results 1 to 3 of 3

    Thread: Code Snippet ;p

    1. #1
      explore Demerzel's Avatar
      Join Date
      Apr 2004
      Gender
      Location
      Scotland, UK
      Posts
      1,189
      Likes
      5

      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 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 &#40;$_GET&#91;'action'&#93;=='poll'&#41; *
      
      ****&#123;
      
       *header&#40;'HTTP/1.1 999 Chatspot Poll OK'&#41;; 
      
       *// Your code here
      
      ****&#125;
      In the XMLHTTPRequest Jscript:
      Code:
      ****// We choose what we do depending on the &#34;error&#34; code the reqlib returns - clever huh? &#58;&#62; *
      
      ****if &#40;req.status == 999&#41; // Polling *
      
      ****&#123;
      
       *// What we do on a poll goes here
      
      ****&#125;
      Hope somebody finds that useful
      [22:59] <Kaniaz> You basically did a massive shit on the rug of this IRC
      [22:59] <Kaniaz> And called it a message

    2. #2
      - Neruo's Avatar
      Join Date
      Dec 2005
      Gender
      Location
      The Netherlands
      Posts
      4,438
      Likes
      5
      Does it bake you waffles? no? stfu.

      lol nah joking. It seems clever, but what does it really do... like in Normal english? ^__^
      “What a peculiar privilege has this little agitation of the brain which we call 'thought'” -Hume

    3. #3
      explore Demerzel's Avatar
      Join Date
      Apr 2004
      Gender
      Location
      Scotland, UK
      Posts
      1,189
      Likes
      5
      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.
      [22:59] <Kaniaz> You basically did a massive shit on the rug of this IRC
      [22:59] <Kaniaz> And called it a message

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •