-
-
Notifications
You must be signed in to change notification settings - Fork 33
Websocket2 Class
wagyourtail edited this page Sep 20, 2020
·
5 revisions
Example: new Websocket2(address)
Initialize, to call this it is easiest to refer to Request.
put a function here for callback. Example:
// headers is a map of String, List<String>
ws.onConnect = (webSocket, headers) => {
chat.log(headers);
}
put a function here for callback. Example:
ws.onTextMessage = (webSocket, message) => {
chat.log(message);
}
put a function here for callback. Example:
ws.onDisconnect = (webSocket, disconnect) => {
chat.log(closeData.reason);
}
put a function here for callback. Example:
ws.onClose = (webSocket, err) => {
chat.log(err);
}
put a function here for callback.
frame is of the WebSocketFrame type
Example:
ws.onFrame = (webSocket, frame) => {
chat.log(frame);
}
A function that tells the websocket to connect
returns this
object
ws.connect()
A function that tells the websocket to close
returns this
object
ws.close()
A function that tells the websocket to close with a specified close code
returns this
object
ws.close(1) // closes the connection with close code 1
A function that sends a text message to the websocket
returns this
object
ws.sendText("text")
A function that returns the NeoVisionaries WebSocket object
realWs = ws.getWs()
class {
this.serverFrame; //frame from server if it exists
this.clientFrame; //frame from client always exists
this.isServer; //boolean whether or not the remote server disconnected you
constructor(serverFrame, clientFrame, isServer);
}