Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:io
  3. WebSocket class
WebSocket
description

WebSocket classabstract

A two-way HTTP communication object for client or server applications.

The stream exposes the messages received. A text message will be of typeString and a binary message will be of typeList<int>.

Implemented types

Constructors

WebSocket()
WebSocket.fromUpgradedSocket(Socketsocket, {String?protocol,bool?serverSide,CompressionOptionscompression =CompressionOptions.compressionDefault})
Creates a WebSocket from an already-upgraded socket.
factory

Properties

closeCodeint?
The close code set when the WebSocket connection is closed. Ifthere is no close code available this property will benull
no setter
closeReasonString?
The close reason set when the WebSocket connection is closed. Ifthere is no close reason available this property will benull
no setter
doneFuture
Return a future which is completed when theStreamSink is finished.
no setterinherited
extensionsString
The extensions property is initially the empty string. After theWebSocket connection is established this string reflects theextensions used by the server.
no setter
firstFuture
The first element of this stream.
no setterinherited
hashCodeint
The hash code for this object.
no setterinherited
isBroadcastbool
Whether this stream is a broadcast stream.
no setterinherited
isEmptyFuture<bool>
Whether this stream contains any elements.
no setterinherited
lastFuture
The last element of this stream.
no setterinherited
lengthFuture<int>
The number of elements in this stream.
no setterinherited
pingIntervalDuration?
The interval between ping signals.
getter/setter pair
protocolString?
The protocol property is initially the empty string. After theWebSocket connection is established the value is the subprotocolselected by the server. If no subprotocol is negotiated thevalue will remainnull.
no setter
readyStateint
Returns the current state of the connection.
no setter
runtimeTypeType
A representation of the runtime type of the object.
no setterinherited
singleFuture
The single element of this stream.
no setterinherited

Methods

add(dynamicdata)→ void
Sends data on the WebSocket connection. The data indata mustbe either aString, or aList<int> holding bytes.
override
addError(Objecterror, [StackTrace?stackTrace])→ void
Adds anerror to the sink.
inherited
addStream(Streamstream)Future
Sends data from a stream on WebSocket connection. Each data event fromstream will be send as a single WebSocket frame. The data fromstreammust be eitherStrings, orList<int>s holding bytes.
override
addUtf8Text(List<int>bytes)→ void
Sends a text message with the text represented bybytes.
any(booltest(dynamicelement))Future<bool>
Checks whethertest accepts any element provided by this stream.
inherited
asBroadcastStream({voidonListen(StreamSubscriptionsubscription)?,voidonCancel(StreamSubscriptionsubscription)?})Stream
Returns a multi-subscription stream that produces the same events as this.
inherited
asyncExpand<E>(Stream<E>?convert(dynamicevent))Stream<E>
Transforms each element into a sequence of asynchronous events.
inherited
asyncMap<E>(FutureOr<E>convert(dynamicevent))Stream<E>
Creates a new stream with each data event of this stream asynchronouslymapped to a new event.
inherited
cast<R>()Stream<R>
Adapt this stream to be aStream<R>.
inherited
close([int?code,String?reason])Future
Closes the WebSocket connection. Set the optionalcode andreasonarguments to send close information to the remote peer. If they areomitted, the peer will seeWebSocketStatus.noStatusReceived codewith no reason.
override
contains(Object?needle)Future<bool>
Returns whetherneedle occurs in the elements provided by this stream.
inherited
distinct([boolequals(dynamicprevious,dynamicnext)?])Stream
Skips data events if they are equal to the previous data event.
inherited
drain<E>([E?futureValue])Future<E>
Discards all data on this stream, but signals when it is done or an erroroccurred.
inherited
elementAt(intindex)Future
Returns the value of theindexth data event of this stream.
inherited
every(booltest(dynamicelement))Future<bool>
Checks whethertest accepts all elements provided by this stream.
inherited
expand<S>(Iterable<S>convert(dynamicelement))Stream<S>
Transforms each element of this stream into a sequence of elements.
inherited
firstWhere(booltest(dynamicelement), {dynamicorElse()?})Future
Finds the first element of this stream matchingtest.
inherited
fold<S>(SinitialValue,Scombine(Sprevious,dynamicelement))Future<S>
Combines a sequence of values by repeatedly applyingcombine.
inherited
forEach(voidaction(dynamicelement))Future<void>
Executesaction on each element of this stream.
inherited
handleError(FunctiononError, {booltest(dynamicerror)?})Stream
Creates a wrapper Stream that intercepts some errors from this stream.
inherited
join([Stringseparator =""])Future<String>
Combines the string representation of elements into a single string.
inherited
lastWhere(booltest(dynamicelement), {dynamicorElse()?})Future
Finds the last element in this stream matchingtest.
inherited
listen(voidonData(dynamicevent)?, {Function?onError,voidonDone()?,bool?cancelOnError})StreamSubscription
Adds a subscription to this stream.
inherited
map<S>(Sconvert(dynamicevent))Stream<S>
Transforms each element of this stream into a new stream event.
inherited
noSuchMethod(Invocationinvocation)→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pipe(StreamConsumerstreamConsumer)Future
Pipes the events of this stream intostreamConsumer.
inherited
reduce(dynamiccombine(dynamicprevious,dynamicelement))Future
Combines a sequence of values by repeatedly applyingcombine.
inherited
singleWhere(booltest(dynamicelement), {dynamicorElse()?})Future
Finds the single element in this stream matchingtest.
inherited
skip(intcount)Stream
Skips the firstcount data events from this stream.
inherited
skipWhile(booltest(dynamicelement))Stream
Skip data events from this stream while they are matched bytest.
inherited
take(intcount)Stream
Provides at most the firstcount data events of this stream.
inherited
takeWhile(booltest(dynamicelement))Stream
Forwards data events whiletest is successful.
inherited
timeout(DurationtimeLimit, {voidonTimeout(EventSinksink)?})Stream
Creates a new stream with the same events as this stream.
inherited
toList()Future<List>
Collects all elements of this stream in aList.
inherited
toSet()Future<Set>
Collects the data of this stream in aSet.
inherited
toString()String
A string representation of this object.
inherited
transform<S>(StreamTransformer<dynamic,S>streamTransformer)Stream<S>
AppliesstreamTransformer to this stream.
inherited
where(booltest(dynamicevent))Stream
Creates a new stream from this stream that discards some elements.
inherited

Operators

operator ==(Objectother)bool
The equality operator.
inherited

Static Properties

userAgentString?
Gets the user agent used for WebSocket connections.
getter/setter pair

Static Methods

connect(Stringurl, {Iterable<String>?protocols,Map<String,dynamic>?headers,CompressionOptionscompression =CompressionOptions.compressionDefault,HttpClient?customClient})Future<WebSocket>
Create a new WebSocket connection. The URL supplied inurlmust use the schemews orwss.

Constants

closed→ constint
closing→ constint
connecting→ constint
Possible states of the connection.
open→ constint
  1. Dart
  2. dart:io
  3. WebSocket class
dart:io library

[8]ページ先頭

©2009-2025 Movatter.jp