开发者

jQuery event listener for POST data that isn't requested by jQuery

开发者 https://www.devze.com 2023-04-12 06:41 出处:网络
I\'ve been hacking away at Jappix Mini. I want to use the existing XMPP over BOSH to get the right effect and have the right product in place for future development. I\'m able to hide the actual inter

I've been hacking away at Jappix Mini. I want to use the existing XMPP over BOSH to get the right effect and have the right product in place for future development. I'm able to hide the actual interface through CSS, choose a username to send to and type a message to send. . this all works well and I'm picking up changes to the now-hidden div and adding plaintext to a div on my page, separate completely from the Jappix Mini UI, every 50ms with a window.setInterval timer, but I don't want to be using that method for production. I know the messages I'm sending to other users, but could recreate the POST data if I had to and do the POST request from within jQuery. . .just no need to at the current point in time.

What I need is a way to get jQuery to listen for incoming messages from other users - if I can catch the POST data as it comes in, then I can update only as I need to.

The response (through Chrome ctrl+shift+i) I want to capture is:

 <body xmlns='http://jabber.org/protocol/httpbind'><message xmlns="jabber:client" to="(myAccount)@(myDomain).com/Jappix Mini (1318160212950)" type="chat" id="33" xml:lang="en" from="thisishidden@(conferenceServerAddress)/(nicknameOfRecipient"><body>this is a test</body></message></body>

Here's the POST headers:

 Request URL:http://(machineWithOpenfire)/http-bind/
 Request Method:POST
 Status Code:200 OK

 POST /http-bind/ HTTP/1.1

 Host: ubuntu
 Connection: keep-alive
 Content-Length: 141
 Origin: h开发者_开发百科ttp://(webserver/localhost)
 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1
 Content-Type: text/xml; charset=UTF-8
 Accept: */*
 Referer: http://(webserver)/test/index4.php
 Accept-Encoding: gzip,deflate,sdch
 Accept-Language: en-US,en;q=0.8
 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
 Cookie: pma_lang=en; pma_mcrypt_iv=74ajr%2FGepsQ%3D; PHPSESSID=71vht8hngec8r5nba8m7uk17p2; JSESSIONID=ahhew73q40f2

payload:

 <body xml:lang='en' rid='785696' sid='e96dfc09' xmlns='http://jabber.org/protocol/httpbind' key='eb20cd86dee9cb99416f1a8521c2d9f09852f490' />

response headers:

 HTTP/1.1 200 OK

 Server: nginx/0.8.54
 Date: Sun, 09 Oct 2011 12:38:42 GMT
 Content-Type: text/xml;charset=UTF-8
 Connection: keep-alive
 Content-Length: 300

Sorry if I make no sense, or if the answer is obvious - I've been up far too long for thinking straightly!

Thanks anyone who can help me! What I'd ideally want is something akin to:

PostObject onChange do function ( dataResponse ){
      addANewDivToASeries with Sender's Name, Message from dataResponse
}


Look for the handleMessageMini function in the mini.js file. Just modify that if you want to access the message. Jappix will handle receiving it when sent.

0

精彩评论

暂无评论...
验证码 换一张
取 消