The created Dam will be CLOSED
An object compatible with the WebSocket interface.
The connection is closed or couldn't be opened.
The connection is in the process of closing.
The connection is not yet open.
The connection is open and ready to communicate.
A string indicating the type of binary data being transmitted by the connection. This should be either "blob" if DOM Blob objects are being used or "arraybuffer" if ArrayBuffer objects are being used.
The dam is closed and will stop the messages
The dam is open and will let messages pass through
The number of bytes of data that have been queued using calls to send() but not yet transmitted to the network. This value resets to zero once all queued data has been sent. This value does not reset to zero when the connection is closed; if you keep calling send(), this will continue to climb. Read only
The extensions selected by the server. This is currently only the empty string or a list of extensions as negotiated by the connection.
An event listener to be called when the WebSocket connection's readyState changes to CLOSED. The listener receives a CloseEvent named "close".
An event listener to be called when the WebSocket connection's readyState changes to CLOSED. The listener receives a CloseEvent named "close".
An event listener to be called when an error occurs. This is a simple event named "error".
An event listener to be called when an error occurs. This is a simple event named "error".
An event listener to be called when a message is received from the server. The listener receives a MessageEvent named "message".
An event listener to be called when a message is received from the server. The listener receives a MessageEvent named "message".
An event listener to be called when the WebSocket connection's readyState changes to OPEN; this indicates that the connection is ready to send and receive data. The event is a simple one with the name "open".
An event listener to be called when the WebSocket connection's readyState changes to OPEN; this indicates that the connection is ready to send and receive data. The event is a simple one with the name "open".
Compatible with the WebSocket readyState, combining the status of the Dam and the ready state of the underlying WebSocket
WebSocket constants (CONNECTING, OPEN, CLOSING, CLOSED)
The URL as resolved by the constructor. This is always an absolute URL. Read only.
Register an event handler of a specific event type on the EventTarget.
Closes the WebSocket connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing.
Dispatch an event, some event are delayed if the Dam is CLOSED
The return value is false if event is cancelable and at least one of the event handlers which handled this event called Event.preventDefault(). Otherwise it returns true.
Removes an event listener from the EventTarget.
Same as the send method of the WebSocket except that this will throw an error if the Dam is closed
The data to send to the server. It may be one of the following types:
Generated using TypeDoc
The Dam simulate a Websocket Opening and Closing Example of use include simulating a connection opening after an authentication
const dam = new Dam(ws); expect(dam.send("test")).to.throw; dam.status = Dam.OPEN; \// the open event is also dispatched expect(dam.send("test")).to.not.throw;