Movatterモバイル変換


[0]ホーム

URL:


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

WebSocketTransformer classabstract

TheWebSocketTransformer provides the ability to upgrade aHttpRequest to aWebSocket connection. It supports bothupgrading a singleHttpRequest and upgrading a stream ofHttpRequests.

To upgrade a singleHttpRequest use the staticupgrade method.

HttpServer server;server.listen((request) {  if (...) {    WebSocketTransformer.upgrade(request).then((websocket) {      ...    });  } else {    // Do normal HTTP request processing.  }});

To transform a stream ofHttpRequest events as it implements astream transformer that transforms a stream of HttpRequest into astream of WebSockets by upgrading each HttpRequest from the HTTP orHTTPS server, to the WebSocket protocol.

server.transform(new WebSocketTransformer()).listen((webSocket) => ...);

This transformer strives to implement WebSockets as specified by RFC6455.

Implemented types

Constructors

WebSocketTransformer({dynamicprotocolSelector(List<String>protocols)?,CompressionOptionscompression =CompressionOptions.compressionDefault})
Create a newWebSocketTransformer.
factory

Properties

hashCodeint
The hash code for this object.
no setterinherited
runtimeTypeType
A representation of the runtime type of the object.
no setterinherited

Methods

bind(Stream<HttpRequest>stream)Stream<WebSocket>
Transforms the providedstream.
inherited
cast<RS,RT>()StreamTransformer<RS,RT>
Provides aStreamTransformer<RS, RT> view of this stream transformer.
inherited
noSuchMethod(Invocationinvocation)→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString()String
A string representation of this object.
inherited

Operators

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

Static Methods

isUpgradeRequest(HttpRequestrequest)bool
Checks whether the request is a valid WebSocket upgrade request.
upgrade(HttpRequestrequest, {dynamicprotocolSelector(List<String>protocols)?,CompressionOptionscompression =CompressionOptions.compressionDefault})Future<WebSocket>
Upgrades anHttpRequest to aWebSocket connection. If therequest is not a valid WebSocket upgrade request an HTTP responsewith status code 500 will be returned. Otherwise the returnedfuture will complete with theWebSocket when the upgrade processis complete.
  1. Dart
  2. dart:io
  3. WebSocketTransformer class
dart:io library

[8]ページ先頭

©2009-2025 Movatter.jp