WebSocketListener Class

Instances of this class are used to process WebSocket requests. Example:

    public class MyServlet extends HttpServlet {

        public MyServlet() {}

        public void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, java.io.IOException {

            if (request.isWebSocket()){
                new WebSocketListener(request, response){
                    public void onConnect(){
                        send("Hello There!");
                    public void onText(String str){
                        send("Message recieved at " + new java.util.Date());

                    public void onDisconnect(int statusCode, String reason, boolean remote){
            else{ //standard http request
                response.write("Hello, the time is now " + new java.util.Date());


public WebSocketListener( javaxt.http.servlet.HttpServletRequest request, javaxt.http.servlet.HttpServletResponse response )


close( ) returns void
Sends a websocket Close frame, with a normal status code and no reason phrase. This will enqueue a graceful close to the remote endpoint.
disconnect( ) returns void
Issues a harsh disconnect of the underlying connection. This will terminate the connection, without sending a websocket close frame.
getCertificates( ) returns java.security.cert.X509Certificate[]
getCookies( ) returns javaxt.http.servlet.Cookie[]
getExtensions( ) returns java.util.Enumeration
getHeader( String name ) returns String
getHeaders( ) returns java.util.Map
getHeaders( String name ) returns java.util.List
getLocalAddress( ) returns String
getLocale( ) returns java.util.Locale
getLocales( ) returns java.util.Enumeration
getLocalHostName( ) returns String
getLocalPort( ) returns int
getParameterMap( ) returns java.util.Map
getProtocolVersion( ) returns String
getRemoteAddress( ) returns String
getRemoteHostName( ) returns String
getRemotePort( ) returns int
getSubProtocols( ) returns java.util.List
getURI( ) returns java.net.URI
Returns the URI used to establish the WebSocket connection.
getUserPrincipal( ) returns java.security.Principal
hasSubProtocol( String test ) returns boolean
isSecure( ) returns boolean
isUserInRole( String role ) returns boolean
onConnect( ) returns void
Called whenever a new WebSocket connection is established.
onDisconnect( int statusCode, String reason ) returns void
Called whenever a WebSocket connection is terminated.
onText( String str ) returns void
Called whenever a client sends a text message to the WebSocket.
send( String str ) returns void
Used to send a text message to the client.