Connect and Disconnect events not working on webSocketSever

These two functions are not getting called by WebSocketServer. What to do to solve it? (I am using this library → GitHub - alexandrainst/processing_websockets: A web socket library, including both server and client, for Processing)

    public void webSocketConnectEvent(String uid, String ip) {
        Logger.log(Logger.LogLevel.INFO, "Someone connected with UID " + uid + "and IP" + ip);
        connectedUsers++;
    }

    public void webSocketDisconnectEvent(String uid, String ip) {
        Logger.log(Logger.LogLevel.INFO, "Someone disconnected with UID " + uid + "and IP" + ip);
        connectedUsers--;
    }

It took me some time to figure this out this problem, but actually the downloadable library on Processing Contribution Manager is an old one. Try replacing it from the one from github (just download the zip, extract it and rename it as websockets)

1 Like

okay i will try that.

i tried it but still its not working :confused:

i did as you said. Downloaded the zip, extracted it, added the folder to the jar list in my intellij project, but still the problem didnt go

oh sorry to hear that. But please be a bit more friendly even though english may not be your mother tongue - like saying “thank you” or “can you help me with…” - because this is not a product support forum but a place for community members to support each other :slight_smile:

The solution worked in my case, and the only difference seems to be that I use Processing IDE and you are using IntelliJ. Can you check first with Processing IDE if the callbacks work for you? If it works, then there may be something wrong with the settings of IntelliJ. If it doesn’t work, it could be that you are still using an old version of the lib or you are not using the callback in the right way.

1 Like

okay i will try it with processing ide.

I tried it on processing ide and it still doesnt work.

I don’t want to repeat it but as I wrote above please add a few more words to sound nicer. If it doesn’t work I don’t know what else to suggest. Maybe you can submit an issue on github if you think this is due to the library?

1 Like

okay! I will try opening an issue on the repository of the library! Can you suggest any other java WebSocket libraries that are easy to use?

Hello @micuat,

Confirming that connect\disconnect events (as per code on website below) worked fine here once I had the latest updates from here:

And this Download ZIP:
image

:)

1 Like

did the disconnect and connect events trigger correctly?

Yes.

There appears to be a ticket for this but it lacks details:

Should I compile the jar from the source and use that jar?

I opened that issue.

I don’t think so, I tried the compiled jar from github and it worked on the IDE as I wrote above. I guess you have issues with installing the library and perhaps your code is still loading the old one. You tested both on IntelliJ and processing IDE with the latest repo and neither worked, right?

1 Like

yes, I tried on both IntelliJ and processing ide and the library doesn’t seem to work

downloaded this processing_websockets/webSockets.zip at master · alexandrainst/processing_websockets · GitHub and it worked!

Hello,

Since you got this to work can you please update the GitHib issue that you opened:

Connect and disconnect events doesn't work. · Issue #22 · alexandrainst/processing_websockets · GitHub

:)

1 Like

Issue closed! Now my issue is solved and I can continue making the server for my game!

1 Like