Class JavaxWebSocketConnection
- java.lang.Object
-
- org.apache.wicket.protocol.ws.api.AbstractWebSocketConnection
-
- org.apache.wicket.protocol.ws.javax.JavaxWebSocketConnection
-
- All Implemented Interfaces:
IWebSocketConnection
public class JavaxWebSocketConnection extends AbstractWebSocketConnection
A wrapper around JSR 356's native Session.- Since:
- 7.0.0
-
-
Constructor Summary
Constructors Constructor Description JavaxWebSocketConnection(javax.websocket.Session session, AbstractWebSocketProcessor webSocketProcessor)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close(int code, String reason)
Closes the underlying web socket connectionboolean
isOpen()
IWebSocketConnection
sendMessage(byte[] message, int offset, int length)
Sends a binary message to the client.IWebSocketConnection
sendMessage(String message)
Sends a text message to the client.Future<Void>
sendMessageAsync(byte[] message, int offset, int length)
Sends a binary message to the client in an asynchronous way.Future<Void>
sendMessageAsync(byte[] message, int offset, int length, long timeOut)
Sends a binary message to the client in an asynchronous way.Future<Void>
sendMessageAsync(String message)
Sends a text message to the client in an asynchronous way.Future<Void>
sendMessageAsync(String message, long timeOut)
Sends a text message to the client in an asynchronous way.-
Methods inherited from class org.apache.wicket.protocol.ws.api.AbstractWebSocketConnection
getApplication, getKey, getSessionId, sendMessage, sendMessageAsync, sendMessageAsync
-
-
-
-
Constructor Detail
-
JavaxWebSocketConnection
public JavaxWebSocketConnection(javax.websocket.Session session, AbstractWebSocketProcessor webSocketProcessor)
Constructor.- Parameters:
session
- the WebSocket session
-
-
Method Detail
-
isOpen
public boolean isOpen()
- Returns:
true
when the underlying native web socket connection is still open.
-
close
public void close(int code, String reason)
Description copied from interface:IWebSocketConnection
Closes the underlying web socket connection- Parameters:
code
- the status codereason
- the reason to close the connection
-
sendMessage
public IWebSocketConnection sendMessage(String message) throws IOException
Description copied from interface:IWebSocketConnection
Sends a text message to the client.- Parameters:
message
- the text message- Returns:
this
object, for chaining methods- Throws:
IOException
- when an IO error occurs during the write to the client
-
sendMessageAsync
public Future<Void> sendMessageAsync(String message)
Description copied from interface:IWebSocketConnection
Sends a text message to the client in an asynchronous way.- Parameters:
message
- the text message- Returns:
- a
Future
representing the send operation
-
sendMessageAsync
public Future<Void> sendMessageAsync(String message, long timeOut)
Description copied from interface:IWebSocketConnection
Sends a text message to the client in an asynchronous way.- Parameters:
message
- the text messagetimeOut
- the timeout for operation- Returns:
- a
Future
representing the send operation
-
sendMessage
public IWebSocketConnection sendMessage(byte[] message, int offset, int length) throws IOException
Description copied from interface:IWebSocketConnection
Sends a binary message to the client.- Parameters:
message
- the binary messageoffset
- the offset to read fromlength
- how much data to read- Returns:
this
object, for chaining methods- Throws:
IOException
- when an IO error occurs during the write to the client
-
sendMessageAsync
public Future<Void> sendMessageAsync(byte[] message, int offset, int length)
Description copied from interface:IWebSocketConnection
Sends a binary message to the client in an asynchronous way.- Parameters:
message
- the binary messageoffset
- the offset to read fromlength
- how much data to read- Returns:
- a
Future
representing the send operation
-
sendMessageAsync
public Future<Void> sendMessageAsync(byte[] message, int offset, int length, long timeOut)
Description copied from interface:IWebSocketConnection
Sends a binary message to the client in an asynchronous way.- Parameters:
message
- the binary messageoffset
- the offset to read fromlength
- how much data to readtimeOut
- the timeout for operation- Returns:
- a
Future
representing the send operation
-
-