Home

# Class goog.net.WebSocket

Class encapsulating the logic for using a WebSocket.

extends goog.events.EventTarget

Instance Method Summary
| `clearReconnectTimer_()` Clears the reconnect timer.
| `close()` Closes the web socket connection.

`disposeInternal()`

Unattach listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners, it should be something like this:

    MyClass.prototype.disposeInternal = function() {
    MyClass.superClass_.disposeInternal.call(this);
    // Dispose logic for MyClass
    };

| `isOpen() ⇒ boolean` Checks to see if the web socket is open or not.
| `onClose_(!Event event)` Called when the web socket has closed.
| `onError_(?Event event)` Called when there is any error in communication.
| `onMessage_(?MessageEvent event)` Called when a new message arrives from the server.
| `onOpen_()` Called when the web socket has connected.
| `open(string url, string= opt_protocol)` Creates and opens the actual WebSocket. Only call this after attaching the appropriate listeners to this object. If listeners aren't registered, then the {@code goog.net.WebSocket.EventType.OPENED} event might be missed.
| `send(string message)` Sends the message over the web socket.

Static Method Summary
| `EXPONENTIAL_BACKOFF_(number attempt) ⇒ number` Computes the next reconnect time given the number of reconnect attempts since the last successful connection.
| `protectEntryPoints(!goog.debug.ErrorHandler errorHandler)` Installs exception protection for all entry points introduced by goog.net.WebSocket instances which are not protected by {@link goog.debug.ErrorHandler#protectWindowSetTimeout}, {@link goog.debug.ErrorHandler#protectWindowSetInterval}, or {@link goog.events.protectBrowserEventEntryPoint}.