BO.WSocketWrapper Class
Creates a wrapper for various websocket implementations to unify the interface.
Constructor
BO.WSocketWrapper
-
host
-
port
-
protocol
Parameters:
-
host
StringThe host address of the web server.
-
port
NumberThe port to connect to on the web server. native websocket implementation.
-
protocol
StringThe websockt protocol definition (if necessary).
Item Index
Properties
Methods
addEventListener
-
type
-
listener
Parameters:
-
type
StringThe event type
-
listener
FunctionThe function to be called when the event is fired
dispatchEvent
-
type
-
optionalParams
Parameters:
-
type
EventThe Event object.
-
optionalParams
ObjectOptional parameters passed as an object. return {boolean} True if dispatch is successful, false if not.
hasEventListener
-
type
Parameters:
-
type
StringThe event type return {boolean} True is listener exists for this type, false if not.
init
-
self
Initialize the websocket
Parameters:
-
self
ObjectA reference to this websocket object.
removeEventListener
-
type
-
listener
Parameters:
-
type
StringThe event type
-
listener
FunctionThe function to be called when the event is fired
send
-
message
Send a message TO DO: support sending ArrayBuffers and Blobs For now, forward any calls to sendString
Parameters:
-
message
StringThe message to send
sendString
-
message
Send a message
Parameters:
-
message
StringThe message to send
Properties
readyState
String
[read-only] Wrapper for the readyState method of the native websocket implementation
CONNECTING = 0, OPEN = 1, CLOSING = 2, CLOSED = 3
Events
webSocketClosed
BO.WebsocketEvent.CLOSE
The webSocketClosed event is dispatched the websocket connection is closed.
Event Payload:
-
target
BO.WSocketWrapperA reference to the WSocketWrapper object.
webSocketConnected
BO.WebsocketEvent.CONNECTED
The webSocketConnected event is dispatched when a connection with the websocket is established.
Event Payload:
-
target
BO.WSocketWrapperA reference to the WSocketWrapper object.
webSocketMessage
BO.WebsocketEvent.MESSAGE
The webSocketMessage event is dispatched when a websocket message is received.
Event Payload:
-
target
BO.WSocketWrapperA reference to the WSocketWrapper object.
-
message
StringThe websocket data