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 Strophe

    Rectangle {
    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 myjs

    myjs.hello();
    @

    Read this for more info:

    http://doc.qt.nokia.com/4.7-snapshot/qdeclarativejavascript.html



  • Thanks kbcool, that was the problem there of course! However it seems that the Strophe.js would require fair amount of tweaking to get it working with the QML so I gave up and search other way to do it.

    Thanks anyway!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.