web_socket_channel
WebSocket용 StreamChannel 래퍼.
- 스타
- 429
- 포크
- 106
- 최근 푸시(UTC)
- 2025. 2. 1.
- 프로젝트 상태
- 보관됨
원본 README
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
[!IMPORTANT]
This repo has moved to https://github.com/dart-lang/http/tree/master/pkgs/web_socket_channel
package:web_socket_channel provides cross-platform
StreamChannel wrappers for WebSocket connections.
Docs and Usage
It provides a cross-platform
WebSocketChannel API, a cross-platform implementation of
that API that communicates over an underlying StreamChannel,
an implementation that wraps dart:io's WebSocket
class, and a similar implementation that wraps
dart:html's.
It also provides constants for the WebSocket protocol's pre-defined status codes
in the status.dart library. It's strongly recommended that users
import this library with the prefix status.
import 'package:web_socket_channel/web_socket_channel.dart';
import 'package:web_socket_channel/status.dart' as status;
main() async {
final wsUrl = Uri.parse('ws://example.com');
final channel = WebSocketChannel.connect(wsUrl);
await channel.ready;
channel.stream.listen((message) {
channel.sink.add('received!');
channel.sink.close(status.goingAway);
});
}
WebSocketChannel
The WebSocketChannel class's most important role is as the
interface for WebSocket stream channels across all implementations and all
platforms. In addition to the base StreamChannel interface, it adds a
protocol getter that returns the negotiated protocol for the
socket, as well as closeCode and closeReason
getters that provide information about why the socket closed.
The channel's sink property is also special. It returns a
WebSocketSink, which is just like a StreamSink except that
its close() method supports optional closeCode and
closeReason parameters. These parameters allow the caller to signal to the
other socket exactly why they're closing the connection.
WebSocketChannel also works as a cross-platform implementation of the
WebSocket protocol. The WebSocketChannel.connect constructor
connects to a listening server using the appropriate implementation for the
platform.
사용 중인 의존성
의존성 목록 7 개
- async
^2.5.0 - crypto
^3.0.0 - stream_channel
^2.1.0 - web
>=0.5.0 <2.0.0 - web_socket
^0.1.5 - dart_flutter_team_lints개발 의존성
^3.0.0 - test개발 의존성
^1.25.2
프로젝트에 맞는 저장소를 선택하려면?
사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.
- 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
- 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
- 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.
출처 및 관리
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗