WebSocket class

Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.

MDN Reference

Implemented types
Available extensions
Annotations
  • @JS()
  • @staticInterop

Constructors

WebSocket(Object url, [Object? protocols])
factory

Properties

addEventListener ↔ void Function(String, [Object?, Object?])

Available on EventTarget, provided by the EventTarget$Typings extension

getter/setter pair
addEventListener → ({void Function<K$>(WebSocketEventMap<K$> type, dynamic listener(K$), [Object? options]) $1, void Function(String type, Object listener, [Object? options]) $2})

Available on WebSocket, provided by the WebSocket$Typings extension

Overload accessor: $1, $2
no setter
binaryType BinaryType

Available on WebSocket, provided by the WebSocket$Typings extension

Returns a string that indicates how binary data from the WebSocket object is exposed to scripts:
getter/setter pair
bufferedAmount num

Available on WebSocket, provided by the WebSocket$Typings extension

Returns the number of bytes of application data (UTF-8 text and binary data) that have been queued using send() but not yet been transmitted to the network.
no setter
close ↔ void Function([num?, String?])

Available on WebSocket, provided by the WebSocket$Typings extension

getter/setter pair
closed num

Available on WebSocket, provided by the WebSocket$Typings extension

no setter
closing num

Available on WebSocket, provided by the WebSocket$Typings extension

no setter
connecting num

Available on WebSocket, provided by the WebSocket$Typings extension

no setter
dispatchEvent bool Function(Event)

Available on EventTarget, provided by the EventTarget$Typings extension

getter/setter pair
extensions String

Available on WebSocket, provided by the WebSocket$Typings extension

Returns the extensions selected by the server, if any.
no setter
hashCode int
The hash code for this object.
no setterinherited
onclose ↔ dynamic Function(CloseEvent)?

Available on WebSocket, provided by the WebSocket$Typings extension

MDN Reference
getter/setter pair
onerror ↔ dynamic Function(Event)?

Available on WebSocket, provided by the WebSocket$Typings extension

MDN Reference
getter/setter pair
onmessage ↔ dynamic Function(MessageEvent)?

Available on WebSocket, provided by the WebSocket$Typings extension

MDN Reference
getter/setter pair
onopen ↔ dynamic Function(Event)?

Available on WebSocket, provided by the WebSocket$Typings extension

MDN Reference
getter/setter pair
open num

Available on WebSocket, provided by the WebSocket$Typings extension

no setter
protocol String

Available on WebSocket, provided by the WebSocket$Typings extension

Returns the subprotocol selected by the server, if any. It can be used in conjunction with the array form of the constructor's second argument to perform subprotocol negotiation.
no setter
readyState num

Available on WebSocket, provided by the WebSocket$Typings extension

Returns the state of the WebSocket object's connection. It can have the values described below.
no setter
removeEventListener ↔ void Function(String, [Object?, Object?])

Available on EventTarget, provided by the EventTarget$Typings extension

getter/setter pair
removeEventListener → ({void Function<K$>(WebSocketEventMap<K$> type, dynamic listener(K$), [Object? options]) $1, void Function(String type, Object listener, [Object? options]) $2})

Available on WebSocket, provided by the WebSocket$Typings extension

Overload accessor: $1, $2
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
send ↔ void Function(Object)

Available on WebSocket, provided by the WebSocket$Typings extension

getter/setter pair
url String

Available on WebSocket, provided by the WebSocket$Typings extension

Returns the URL that was used to establish the WebSocket connection.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

closed num
no setter
closing num
no setter
connecting num
no setter
open num
no setter