Version: 9.4.14.v20181114 |

WebSocket Session
Previous | Chapter 27. Jetty Websocket API Home | Next

##### Contact the core Jetty developers at www.webtide.com

private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services for sponsored feature development

## WebSocket Session

The Session object can be used to:

The Connection State (is it open or not).

    if(session.isOpen()) {
      // send message
    }

Is the Connection Secure.

    if(session.isSecure()) {
      // connection is using 'wss://'
    }

What was in the Upgrade Request and Response.

    UpgradeRequest req = session.getUpgradeRequest();
    String channelName = req.getParameterMap().get("channelName");

    UpgradeResponse resp = session.getUpgradeResponse();
    String subprotocol = resp.getAcceptedSubProtocol();

What is the Local and Remote Address.

    InetSocketAddress remoteAddr = session.getRemoteAddress();

Get and Set the Idle Timeout

    session.setIdleTimeout(2000); // 2 second timeout

Previous | Top | Next
WebSocket Events | Home | Send Messages to Remote Endpoint

See an error or something missing? Contribute to this documentation at Github!(Generated: 2018-11-14)