Websockets Library Issues (WebsocketClient constructor)

Hello guys!
I’m having some issue with the websockets library.
In the “docs” (aka the github repo) the WebsocketClient class has several different constructor forms. The main one I’m trying to use, is the primary form:

public WebsocketClient(PApplet parent, Object callbacks, String endpointURI, StringList headers){}
Extra

The last argument “StringList headers” isn’t actually necessary for the library to work, but it’s included in the patch that has the functionality I’m looking for.

Typically, when using websockets, the main constructor only relies on the

public WebsocketClient(PApplet parent, String endpointURI) { }

which hooks back into the main constructor. In the code, the author left a comment on as to how to use the primary constructor, but I’m having issues.
The default processing library (v0.01) seems to either not support this constructor method, or just doesn’t include it yet.
I tried to update it via copying the .src from the main repo, with no dice.
I did the same with the .library and also, no dice.

I’m at the end of my rope with trying to figure out why it won’t work, when in reality it should.

If you have any suggestions as to what I could try to resolve this, that would be amazing! Thank you!

Hi @Mattyjak,

I have looked at the git repository and the included jar.
Unfortunately the included library doesn’t include the constructor you want from above, but I can see it in the source code as well. So I don’t know how experienced you are in terms of building the lib on your own, but that would be one way to make it work…

Cheers
— mnse

3 Likes

Yes same observation here, I also tried manually putting the downloaded source code in a libraries folder in the Sketch folder without success but you might want to try it. (maybe I was missing the library name / import) :wink:

1 Like

Yeah that looks to be the only way to get the functionality I want. The only issue is that the included constructors seem to have a few different methods for the actual interfacing with the real websocket client class, so I’d probably have to rewrite that as a whole.

Thanks anyways, I’ll try and find a way.

Tried that before, still no dice.
I also tried the java files from the src folder too.
Neither seem to work, but I’ll try and see if reinstalling it as a whole might work.

I GOT IT TO WORK.

I was being stupid.

I’ve moved PCs recently, so all my old files are in different spots from my new ones, so when I reinstalled processing, the library folder I was using was from the old directory.

All I had to do was to replace the old .library files with the ones from the github, and it works!
I was just saving them to the wrong spot.
Thank you for the help again!

1 Like