Package ninja.websockets
Class AbstractWebSocketHandshake
- java.lang.Object
-
- ninja.websockets.AbstractWebSocketHandshake
-
- All Implemented Interfaces:
WebSocketHandshake
public abstract class AbstractWebSocketHandshake extends Object implements WebSocketHandshake
-
-
Constructor Summary
Constructors Constructor Description AbstractWebSocketHandshake()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<String>
getRequestedProtocols()
The sub protocols requested by the client.String
getSelectedProtocol()
Gets the current selected sub protocol out of the requested sub protocols.boolean
selectProtocol(String subprotocol)
Selects the first matching supported sub protocol out of the requested sub protocols.void
setRequestedProtocols(Set<String> requestedProtocols)
-
-
-
Method Detail
-
getRequestedProtocols
public Set<String> getRequestedProtocols()
Description copied from interface:WebSocketHandshake
The sub protocols requested by the client. Will be ordered to match the order sent by the client.- Specified by:
getRequestedProtocols
in interfaceWebSocketHandshake
- Returns:
- The set of sub protocols requested by the client or null if the header was empty or never sent by the client.
-
getSelectedProtocol
public String getSelectedProtocol()
Description copied from interface:WebSocketHandshake
Gets the current selected sub protocol out of the requested sub protocols.- Specified by:
getSelectedProtocol
in interfaceWebSocketHandshake
- Returns:
- The selected sub protocol or null if none are selected
-
selectProtocol
public boolean selectProtocol(String subprotocol)
Description copied from interface:WebSocketHandshake
Selects the first matching supported sub protocol out of the requested sub protocols. Most browsers and WebSocket implementations require a match from the list supplied by the client or the handshake will fail.- Specified by:
selectProtocol
in interfaceWebSocketHandshake
- Returns:
- True if selected or false if none matched
-
-