Version: 9.4.7.v20170914 |

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");

    UpgradeRespons 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: 2017-09-14)