Top Description Fields Constructors Methods
org.java_websocket

public abstract Class WebSocketAdapter

extends Object
implements WebSocketListener
Class Inheritance
All Implemented Interfaces
org.java_websocket.WebSocketListener
Known Direct Subclasses
org.java_websocket.AbstractWebSocket
Imports
org.java_websocket.drafts.Draft, org.java_websocket.exceptions.InvalidDataException, org.java_websocket.framing.Framedata, .PingFrame, .PongFrame, org.java_websocket.handshake.ClientHandshake, .HandshakeImpl1Server, .ServerHandshake, .ServerHandshakeBuilder

This class default implements all methods of the WebSocketListener that can be overridden optionally when advances functionalities is needed.

Field Summary

Modifier and TypeField and Description
private PingFrame

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public PingFrame

Returns:

PingFrame to be sent.
onPreparePing
(WebSocket
The WebSocket connection from which the ping frame will be sent.
conn
)

Implements org.java_websocket.WebSocketListener.onPreparePing.

Default implementation for onPreparePing, returns a (cached) PingFrame that has no application data.

public void
onWebsocketHandshakeReceivedAsClient(WebSocket conn, ClientHandshake request, ServerHandshake response)

Implements org.java_websocket.WebSocketListener.onWebsocketHandshakeReceivedAsClient.

Called on the client side when the socket connection is first established, and the WebSocketImpl handshake response has been received.

public ServerHandshakeBuilder
public void
onWebsocketHandshakeSentAsClient(WebSocket conn, ClientHandshake request)

Implements org.java_websocket.WebSocketListener.onWebsocketHandshakeSentAsClient.

This default implementation does not do anything which will cause the connections to always progress.

public void
onWebsocketPing(WebSocket conn, Framedata f)

Implements org.java_websocket.WebSocketListener.onWebsocketPing.

This default implementation will send a pong in response to the received ping.

public void
onWebsocketPong(WebSocket conn, Framedata f)

Implements org.java_websocket.WebSocketListener.onWebsocketPong.

This default implementation does not do anything.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

pingFrameback to summary
private PingFrame pingFrame

Constructor Detail

WebSocketAdapterback to summary
public WebSocketAdapter()

Method Detail

onPreparePingback to summary
public PingFrame onPreparePing(WebSocket conn)

Implements org.java_websocket.WebSocketListener.onPreparePing.

Default implementation for onPreparePing, returns a (cached) PingFrame that has no application data.

Parameters
conn:WebSocket

The WebSocket connection from which the ping frame will be sent.

Returns:PingFrame

PingFrame to be sent.

Annotations
@Override
See Also
org.java_websocket.WebSocketListener#onPreparePing(WebSocket)
onWebsocketHandshakeReceivedAsClientback to summary
public void onWebsocketHandshakeReceivedAsClient(WebSocket conn, ClientHandshake request, ServerHandshake response) throws InvalidDataException

Implements org.java_websocket.WebSocketListener.onWebsocketHandshakeReceivedAsClient.

Doc from org.java_websocket.WebSocketListener.onWebsocketHandshakeReceivedAsClient.

Called on the client side when the socket connection is first established, and the WebSocketImpl handshake response has been received.

Annotations
@Override
Exceptions
InvalidDataException:
Allows the client to reject the connection with the server in respect of its handshake response.
onWebsocketHandshakeReceivedAsServerback to summary
public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer(WebSocket conn, Draft draft, ClientHandshake request) throws InvalidDataException

Implements org.java_websocket.WebSocketListener.onWebsocketHandshakeReceivedAsServer.

This default implementation does not do anything. Go ahead and overwrite it.

Annotations
@Override
Exceptions
InvalidDataException:

Doc from org.java_websocket.WebSocketListener.onWebsocketHandshakeReceivedAsServer.

Throwing this exception will cause this handshake to be rejected

See Also
org.java_websocket.WebSocketListener#onWebsocketHandshakeReceivedAsServer(WebSocket, Draft, ClientHandshake)
onWebsocketHandshakeSentAsClientback to summary
public void onWebsocketHandshakeSentAsClient(WebSocket conn, ClientHandshake request) throws InvalidDataException

Implements org.java_websocket.WebSocketListener.onWebsocketHandshakeSentAsClient.

This default implementation does not do anything which will cause the connections to always progress.

Annotations
@Override
Exceptions
InvalidDataException:

Doc from org.java_websocket.WebSocketListener.onWebsocketHandshakeSentAsClient.

Allows the client to stop the connection from progressing

See Also
org.java_websocket.WebSocketListener#onWebsocketHandshakeSentAsClient(WebSocket, ClientHandshake)
onWebsocketPingback to summary
public void onWebsocketPing(WebSocket conn, Framedata f)

Implements org.java_websocket.WebSocketListener.onWebsocketPing.

This default implementation will send a pong in response to the received ping. The pong frame will have the same payload as the ping frame.

Annotations
@Override
See Also
org.java_websocket.WebSocketListener#onWebsocketPing(WebSocket, Framedata)
onWebsocketPongback to summary
public void onWebsocketPong(WebSocket conn, Framedata f)

Implements org.java_websocket.WebSocketListener.onWebsocketPong.

This default implementation does not do anything. Go ahead and overwrite it.

Annotations
@Override
See Also
org.java_websocket.WebSocketListener#onWebsocketPong(WebSocket, Framedata)