public class WebSocketHelper extends VertxHelperBase
WebSocketServerHelper
VertxHelperBase.AccessorVerticle
HelperBase.DATA_TYPE
_verticle, _vertx
_actor, _currentObj
Modifier and Type | Method and Description |
---|---|
protected void |
_sendMessageOverSocket(java.lang.Object message)
Send the specified message over the websocket.
|
void |
close()
Close the web socket.
|
static WebSocketHelper |
createClientSocket(java.lang.Object actor,
jdk.nashorn.api.scripting.ScriptObjectMirror currentObj,
java.lang.String host,
boolean sslTls,
int port,
java.lang.String receiveType,
java.lang.String sendType,
int connectTimeout,
int numberOfRetries,
int timeBetweenRetries,
boolean trustAll,
java.lang.String trustedCACertPath,
boolean discardMessagesBeforeOpen,
int throttleFactor)
Create a WebSocketHelper instance for the specified JavaScript
Socket instance for the client side of the socket.
|
static WebSocketHelper |
createServerSocket(java.lang.Object actor,
jdk.nashorn.api.scripting.ScriptObjectMirror currentObj,
io.vertx.core.http.WebSocketBase serverWebSocket,
WebSocketServerHelper helper,
java.lang.String receiveType,
java.lang.String sendType)
Create a WebSocketHelper instance for the specified JavaScript
Socket instance for the server side of the socket.
|
boolean |
isOpen()
Return whether the web socket is opened successfully.
|
void |
open()
Open the web socket.
|
void |
send(java.lang.Object msg)
Send data through the web socket.
|
static java.lang.String[] |
supportedReceiveTypes()
Return an array of the types supported by the current host for
receiveType arguments.
|
static java.lang.String[] |
supportedSendTypes()
Return an array of the types supported by the current host for
sendType arguments.
|
_issueOrDeferResponse, _processPendingJob, _setBusy, closeVertx, getHelper, getImageTypes, reset, submit, undeploy
_appendNumericToBuffer, _appendToBuffer, _error, _error, _error, _error, _extractFromBuffer, _issueResponse, _removeDuplicates, _sizeOfType, _toJavaBytes, _toJSArray, getHelping
public void close()
public static WebSocketHelper createClientSocket(java.lang.Object actor, jdk.nashorn.api.scripting.ScriptObjectMirror currentObj, java.lang.String host, boolean sslTls, int port, java.lang.String receiveType, java.lang.String sendType, int connectTimeout, int numberOfRetries, int timeBetweenRetries, boolean trustAll, java.lang.String trustedCACertPath, boolean discardMessagesBeforeOpen, int throttleFactor)
actor
- The actor associated with this helper.currentObj
- The JavaScript instance of the Socket.host
- IP address or host name of the host.port
- The port number that the host listens on.sslTls
- Whether SSL/TLS is enabled. This defaults to false.receiveType
- The type to assume for incoming messages.sendType
- The type for outgoing messages.connectTimeout
- The time to wait before giving up on a connection.numberOfRetries
- The number of retries.timeBetweenRetries
- The time between retries, in milliseconds.trustAll
- Whether to trust any server certificate. This defaults to false.trustedCACertPath
- The filename for the file that stores the x.509 certificate of a certificate authority (CA) in PEM format.discardMessagesBeforeOpen
- True to discard messages before the socket is open. False to queue them.throttleFactor
- The number of milliseconds to stall for each queued item waiting to be sent.public static WebSocketHelper createServerSocket(java.lang.Object actor, jdk.nashorn.api.scripting.ScriptObjectMirror currentObj, io.vertx.core.http.WebSocketBase serverWebSocket, WebSocketServerHelper helper, java.lang.String receiveType, java.lang.String sendType)
actor
- The actor associated with this helper.currentObj
- The JavaScript instance of the Socket.serverWebSocket
- The given server-side Java socket.helper
- The helper in charge of this socket.receiveType
- The type to assume for incoming messages.sendType
- The type for outgoing messages.public boolean isOpen()
public void open()
public void send(java.lang.Object msg) throws IllegalActionException
msg
- A message to be sent.IllegalActionException
- If establishing the connection to the web socket has
permanently failed.public static java.lang.String[] supportedReceiveTypes()
public static java.lang.String[] supportedSendTypes()
protected void _sendMessageOverSocket(java.lang.Object message)
message
- The message.