QML and strophe.js
-
I'm experimenting using Strophe.js http://strophe.im/strophejs/ to get BOSH connection between my server and QML app (mostly because it would make HTML5<->QML porting reeeally easy in case of certain kind of apps that use BOSH). I have nothing else but a qml with import strophe.js as Strophe and there I try to var connection = new Strophe.Connection(myBoshServer) as told in strophe tutorial.
Result is: TypeError: Result of expression 'Strophe.Connection' [undefined] is not a constructor.
I have absolutely no idea why / what that means. Same stuff works perfectly as a HTML5 app.
Any ideas? Thanks!
Additional info from strophe.js:
@/** Constructor: Strophe.Connection
- Create and initialize a Strophe.Connection object.
- Parameters:
- (String) service - The BOSH service URL.
- Returns:
- A new Strophe.Connection object.
*/
Strophe.Connection = function (service)
{
...
@
edit: and here's the whole thing of beauty:
@import QtQuick 1.1
import "./strophe.js" as StropheRectangle {
width: 640
height: 360
MouseArea {
anchors.fill: parent
onClicked: {
var connection = new Strophe.Connection("http://bosh.metajack.im:5280/xmpp-httpbind");
}
}
}
@ -
Try changing:
@var connection = new Strophe.Connection("http://bosh.metajack.im:5280/xmpp-httpbind");@
to
@var connection = new Strophe.Strophe.Connection("http://bosh.metajack.im:5280/xmpp-httpbind");@
When you import a js file all the variables and functions are given the namespace under the as ....
Eg:
@
import "myjs.js" as myjsmyjs.hello();
@Read this for more info:
http://doc.qt.nokia.com/4.7-snapshot/qdeclarativejavascript.html