Package net.targetr.rc.client
Class ClientWebSocketHandler
java.lang.Object
net.targetr.rc.client.ClientWebSocketHandler
- All Implemented Interfaces:
SocketExceptionHandler
Communicates with a client using a WebSocket.
- Author:
- Dr Michael Gardiner
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AtomicIntegerCounter for connected clients.static final longMaximum idle period before checking connection status.static final intWebSocket connection timeout in milliseconds. -
Constructor Summary
ConstructorsConstructorDescriptionClientWebSocketHandler(HttpRequest httpReq) Constructs a new WebSocket handler for the given request. -
Method Summary
Modifier and TypeMethodDescriptionCompletes the WebSocket handshake and manages the live connection.voidAdds support to a HttpResponder for capturing an exception during write.
-
Field Details
-
TIMEOUT
public static final int TIMEOUTWebSocket connection timeout in milliseconds.- See Also:
-
IDLE_PERIOD
public static final long IDLE_PERIODMaximum idle period before checking connection status.- See Also:
-
clientCount
Counter for connected clients.
-
-
Constructor Details
-
ClientWebSocketHandler
Constructs a new WebSocket handler for the given request.- Parameters:
httpReq- the incoming HTTP upgrade request
-
-
Method Details
-
generateResponse
Completes the WebSocket handshake and manages the live connection.- Returns:
- an HTTP response for the protocol upgrade
- Throws:
IOException- if network communication failsNoSuchAlgorithmException- if handshake hashing fails
-
handleException
Description copied from interface:SocketExceptionHandlerAdds support to a HttpResponder for capturing an exception during write.- Specified by:
handleExceptionin interfaceSocketExceptionHandler- Parameters:
ex- an exception occurred while sending data to client.
-