- All Known Implementing Classes:
JettyWebSocketAdapter
public interface WebSocketAdapter
Helper to have no direct dependency to the WebSockt client
implementation used by HtmlUnit.
- Author:
- Ronald Brill
-
Method Summary
Modifier and TypeMethodDescriptionvoidClose the client.voidClose the incoming session.voidClose the outgoing session.default voidcloseOutgoingSession(int statusCode, String reason) Close the outgoing session with the given status code and reason.voidConnects to the givenURI.default voidConnects to the givenURIand offers the given sub-protocols in the handshake.default StringReturns the sub-protocol the server selected in the handshake.voidSends the provided content.voidstart()Starts the client.
-
Method Details
-
start
Starts the client.- Throws:
Exception- in case of error
-
connect
Connects to the givenURI.- Parameters:
url- the target url- Throws:
Exception- in case of error
-
connect
Connects to the givenURIand offers the given sub-protocols in the handshake. The default implementation ignores the sub-protocols, so adapters without support keep working (no sub-protocol is selected then).- Parameters:
url- the target urlprotocols- the sub-protocols to offer, may be empty- Throws:
Exception- in case of error
-
getSelectedProtocol
Returns the sub-protocol the server selected in the handshake. Only meaningful once the connection is open.- Returns:
- the selected sub-protocol, or an empty string if the server did not select one
-
send
Sends the provided content.- Parameters:
content- the content to be sent- Throws:
IOException- in case of error
-
closeIncomingSession
Close the incoming session.- Throws:
Exception- in case of error
-
closeOutgoingSession
Close the outgoing session.- Throws:
Exception- in case of error
-
closeOutgoingSession
Close the outgoing session with the given status code and reason. The status code 1005 means that no status code at all is sent (an empty close frame), the reason is only sent together with a status code. The default implementation ignores the arguments and does the same ascloseOutgoingSession(), so existing implementations keep working.- Parameters:
statusCode- the status code of the close framereason- the reason of the close frame, may be empty- Throws:
Exception- in case of error
-
closeClient
Close the client.- Throws:
Exception- in case of error
-