Question: After the [C++ socketio library](https://github.com/socketio/socket.io-client-cpp) has failed me, I'm trying to use the JavaScript library in QT's QML. I copied the client from <https://cdn.socket.io/socket.io-1.4.5.js> to `socketio145.js`.

When I import it as such:

```
.import "socketio145.js" as IO;

```

Running:

```
socket = IO.io();

```

Fails with the error `"[error stack]Expected token :'\n"` on the 3rd line of `socketio145.js`. Is this some non-qml compliant javascript code or is something else going on? I'm lost.

Answer: 
I made something that solves the problem.
I have not had any luck with this at all. I tried compiling SocketIO's C++ library into my project, tried including the JS. But nothing worked and libraries were just confused.

So I took the Qt QWebSocket and wrapped it in a warm and fuzzy coat that looks and works in qml very similarly to how SocketIO works in Javascript. 

<https://github.com/Dimcon/ParthanonsQWebSocketIO>

It works on both Desktop and Android and all you have to do is copy the parthanonsQWebSocket.h file into your project and add in the class to your QML. More details on the readme.

I hope this helps you guys from struggling with this issue the way I did :( :)
I don't have any details of JS library you are referring but here is way to use your own JS code inside QML.
1. Put your JS file into a resource file like this

```
   <qresource prefix="/js">
      <file alias="DataManager.js">qml/js/DataManager.js</file>
   </qresource>

```

2. Inside your QML file use the following import

import "qrc:/js/DataManager.js" as DataManager
3. And use JS like below :

```
Item {
id : win
visible: true
width: 640*2
height: 480*1.5

property var constellationManager;

Component.onCompleted: {
    win.constellationManager = new ConstellationDataManager.ConstellationDataManager();
}

```

}