#gzip on; #增加 upstream bk.openfire { server 127.0.0.1:7070; } location / { root html; index index.html index.htm; } 后面增加 : location /http-bind { proxy_pass http://bk.openfire; proxy_buffering off; proxy_redirect off; proxy_read_timeout 120; proxy_connect_timeout 120; } |
在 httpd.conf 中加入下面幾行:
LoadModule proxy_module modules/mod_proxy.so ProxyRequests Off |
function onConnect(status) { if (status == Strophe.Status.CONNECTING) { log('Strophe is connecting.'); } else if (status == Strophe.Status.CONNFAIL) { log('Strophe failed to connect.'); $('#connect').get(0).value = 'connect'; } else if (status == Strophe.Status.DISCONNECTING) { log('Strophe is disconnecting.'); } else if (status == Strophe.Status.DISCONNECTED) { log('Strophe is disconnected.'); $('#connect').get(0).value = 'connect'; } else if (status == Strophe.Status.CONNECTED) { log('Strophe is connected.'); connection.addHandler(onMessage, null, 'message', null, null, null); connection.send($pres().tree()); } } |
connection = new Strophe.Connection(BOSH_SERVICE); connection.rawInput = rawInput; connection.rawOutput = rawOutput; //Strophe.log = function (level, msg) { log('LOG: ' + msg); }; $('#connect').bind('click', function () { var button = $('#connect').get(0); if (button.value == 'connect') { button.value = 'disconnect'; fromId = $('#jid').val(); toId = $('#tojid').val(); log(fromId); log(toId); connection.connect($('#jid').get(0).value, $('#pass').get(0).value, onConnect); } else { button.value = 'connect'; connection.disconnect(); } }); |
function onMessage(msg) { to = msg.getAttribute('from'); var from = msg.getAttribute('from'); var type = msg.getAttribute('type'); var elems = msg.getElementsByTagName('body'); if (type == "chat" && elems.length > 0) { var body = elems[0]; appendToHis(new Date().toLocaleTimeString() + ' ' + from + ' say: ' + Strophe.getText(body)); } // we must return true to keep the handler alive. // returning false would remove it after it finishes. return true; } |
msg=$('#msg').val(); toId = $('#tojid').val(); var reply = $msg({to: toId, from: fromId , type: 'chat'}).cnode(Strophe.xmlElement('body', '' ,msg)); connection.send(reply.tree()); |
| connection.disconnect(); |
function log(msg) { $('#log').append('<div></div>').append(document.createTextNode(msg)); } |
connection.rawInput = rawInput; connection.rawOutput = rawOutput; ... function rawInput(data) { log('RECV: ' + data); } function rawOutput(data) { log('SENT: ' + data); } |
聯(lián)系客服