public class WebSocketHelper extends Object
| Constructor and Description |
|---|
WebSocketHelper() |
WebSocketHelper(Long asyncTimeout)
Creates a helper object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
sendBasicMessageAsync(javax.websocket.Session session,
BasicMessage msg)
Converts the given message to JSON and sends that JSON text to clients asynchronously.
|
void |
sendBasicMessageSync(javax.websocket.Session session,
BasicMessage msg) |
void |
sendBinaryAsync(javax.websocket.Session session,
InputStream inputStream,
ExecutorService threadPool)
Sends binary data to a client asynchronously.
|
void |
sendBinarySync(javax.websocket.Session session,
InputStream inputStream)
Sends binary data to a client synchronously.
|
void |
sendSync(javax.websocket.Session session,
BasicMessageWithExtraData<? extends BasicMessage> message)
Delegates to either
sendBasicMessageSync(Session, BasicMessage) or
sendBinarySync(Session, InputStream) based on message.getBinaryData() == null. |
void |
sendTextAsync(javax.websocket.Session session,
String text) |
void |
sendTextSync(javax.websocket.Session session,
String text) |
public WebSocketHelper()
public WebSocketHelper(Long asyncTimeout)
timeout - number of milliseconds before an asynchronous send will timeout. A negative number means no
timeout, null means use the WebSocket default timeout.public void sendTextSync(javax.websocket.Session session,
String text)
throws IOException
IOExceptionpublic void sendBasicMessageSync(javax.websocket.Session session,
BasicMessage msg)
throws IOException
IOExceptionpublic void sendTextAsync(javax.websocket.Session session,
String text)
public void sendBasicMessageAsync(javax.websocket.Session session,
BasicMessage msg)
session - the client session where the JSON message will be sentmsg - the message to be converted to JSON and sentpublic void sendSync(javax.websocket.Session session,
BasicMessageWithExtraData<? extends BasicMessage> message)
throws IOException
sendBasicMessageSync(Session, BasicMessage) or
sendBinarySync(Session, InputStream) based on message.getBinaryData() == null.session - the session to send tomessage - the message to sendIOExceptionpublic void sendBinaryAsync(javax.websocket.Session session,
InputStream inputStream,
ExecutorService threadPool)
session - the client session where the message will be sentinputStream - the binary data to sendthreadPool - where the job will be submitted so it can execute asynchronouslypublic void sendBinarySync(javax.websocket.Session session,
InputStream inputStream)
throws IOException
session - the client where the message will be sentinputStream - the binary data to sendIOException - if a problem occurred during delivery of the data to a session.Copyright © 2014–2017 Red Hat, Inc.. All rights reserved.