On the browser side I had automatic reconnects implemented, whenever the
Websockets connection was closed.

But now I am trying to detect, that a player is already connected in
another browser tab and then send a custom close status 4000 from Jetty (so
that automatic reconnect is disabled there and a dialog is displayed to the
user, offering to reconnect):

    // called by the onWebSocketText Jetty-callback
    private void handleLogin(String username, String password) throws
Exception {
        // check username + password and then send the player her/his open
games
        mSession.getRemote().sendStringByFuture(mServlet.getGames(mUid));

        // if oldSession is not null and still open,
        // then the player has several browser tabs open or
        // uses the mobile and the desktop app at the same time
        Session oldSession = SESSIONS.put(mUid, mSession);
        try {
            oldSession.close(4000, "another game session detected");
            oldSession.disconnect();
        } catch (Exception ex) {
            // ignore
        }

However this only works sporadically, I rarely see the code 4000 in the
browser.

Is this caused by the half open connections too?

Thank you
Alex
_______________________________________________
jetty-users mailing list
[email protected]
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/jetty-users

Reply via email to