WebSocket
- internal implementation type representing the socketpublic interface WSTransfer<WebSocket>
context
in your own Contexts.Provider
.
Since introduction of technology identifiers
one can choose between
different background implementations to handle the conversion and
communication requests. The known providers include
org.netbeans.html:ko4j
module which registers
a native browser implementation called websocket, and a
org.netbeans.html:ko-ws-tyrus
module which registers
Java based implementation named tyrus.Modifier and Type | Method and Description |
---|---|
void |
close(WebSocket socket)
A request to close the socket.
|
WebSocket |
open(java.lang.String url,
JSONCall callback)
Initializes a web socket.
|
void |
send(WebSocket socket,
JSONCall data)
Sends data to the server.
|
WebSocket open(java.lang.String url, JSONCall callback)
callback
object should
have mostly empty values: JSONCall.isDoOutput()
should be
false
and thus there should be no JSONCall.getMessage()
.
The method of connection JSONCall.getMethod()
is "WebSocket".
Once the connection is open call notifySuccess(null)
.
When the server sends some data then, pass them to
notifySuccess
method
as well. If there is an error call JSONCall.notifyError(java.lang.Throwable)
.url
- the URL to connect tocallback
- a way to provide results back to the clientvoid send(WebSocket socket, JSONCall data)
data
parameter is JSONCall.getMessage()
,
rest can be ignored.socket
- internal representation of the socketdata
- the message to be sentvoid close(WebSocket socket)
socket
- internal representation of the socketCopyright © 2021 The Apache Software Foundation. All rights reserved.