iperity / node-strophe Goto Github PK
View Code? Open in Web Editor NEW[?] A Node.js compatible version of Strophe.js, borrowed from https://github.com/dhruvbird/node-xmpp-bosh.
[?] A Node.js compatible version of Strophe.js, borrowed from https://github.com/dhruvbird/node-xmpp-bosh.
This function here
Line 2218 in c06c157
is triggered also by the setTimeout function. In that case, the xhr state might change, sometime result in the following error:
Error: INVALID_STATE_ERR: connection must be opened before send() is called
I have installed the node-strophe package within my NodeBB website. However I get an error '$ is not defined' even if I just include the following line of code :
var strophe = require("node-strophe");
OR
var strophe = require("node-strophe").Strophe;
Can anyone help me resolve this issue ?
contextify is no longer a dependency in jsdom, because it's built in to node. Also and does not even compile nan (which contextify depends on) unless people have c++11.
I would appreciate it if you could update node-strophe package to use the latest jsdom? Thanks
Hi,
Probably someone that has gone through this before or hopefully. I'm calling body.c() as follows;
var $myParams = body.c('MyParams', { 'xmlns' : 'http://bindings.cc.com/chat'});
However if I console log this right after the call, body contains; myparams xmlns='http://bindings.cc.com/chat'
Any ideas... i've further debugged and after hours and hours I can't find where this is happening. I'm suspecting in the DOM somewhere.
I tried to make my own branch and do a pull request but I am not authorized apparently. Just paste this code above sendIQ please:
/** Function: sendPresence
* Helper function to send presence stanzas. The main benefit is for
* sending presence stanzas for which you expect a responding presence
* stanza with the same id (for example when leaving a chat room).
*
* Parameters:
* (XMLElement) elem - The stanza to send.
* (Function) callback - The callback function for a successful request.
* (Function) errback - The callback function for a failed or timed
* out request. On timeout, the stanza will be null.
* (Integer) timeout - The time specified in milliseconds for a
* timeout to occur.
*
* Returns:
* The id used to send the presence.
*/
sendPresence: function(elem, callback, errback, timeout) {
var timeoutHandler = null;
var that = this;
if (typeof(elem.tree) === "function") {
elem = elem.tree();
}
var id = elem.getAttribute('id');
if (!id) { // inject id if not found
id = this.getUniqueId("sendPresence");
elem.setAttribute("id", id);
}
if (typeof callback === "function" || typeof errback === "function") {
var handler = this.addHandler(function (stanza) {
// remove timeout handler if there is one
if (timeoutHandler) {
that.deleteTimedHandler(timeoutHandler);
}
var type = stanza.getAttribute('type');
if (type === 'error') {
if (errback) {
errback(stanza);
}
} else if (callback) {
callback(stanza);
}
}, null, 'presence', null, id);
// if timeout specified, set up a timeout handler.
if (timeout) {
timeoutHandler = this.addTimedHandler(timeout, function () {
// get rid of normal handler
that.deleteHandler(handler);
// call errback on timeout with null stanza
if (errback) {
errback(null);
}
return false;
});
}
}
this.send(elem);
return id;
},
var c = new Strophe.Connection("wss://example.com/websocket/");
c.connect(jid, pass);
This error comes out and I cannot find a way to fix it.
Error: Protocol not supported.
at send (/Users/jonathan/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:299:15)
at sendFunc (/Users/jonathan/node_modules/node-strophe/strophe.js:2218:25)
at Object._processRequest (/Users/jonathan/node_modules/node-strophe/strophe.js:2229:17)
at Object._throttledRequestHandler (/Users/jonathan/node_modules/node-strophe/strophe.js:2266:18)
at Object.connect (/Users/jonathan/node_modules/node-strophe/strophe.js:1648:14)
at repl:1:12
at sigintHandlersWrap (vm.js:22:35)
at sigintHandlersWrap (vm.js:96:12)
at ContextifyScript.Script.runInThisContext (vm.js:21:12)
at REPLServer.defaultEval (repl.js:313:29)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.