Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stevenroose/dart-websockets
A generic WebSocket package for Dart
https://github.com/stevenroose/dart-websockets
Last synced: 3 months ago
JSON representation
A generic WebSocket package for Dart
- Host: GitHub
- URL: https://github.com/stevenroose/dart-websockets
- Owner: stevenroose
- License: mit
- Created: 2015-06-16T01:03:32.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-10-16T17:06:45.000Z (over 8 years ago)
- Last Synced: 2024-10-09T22:11:48.047Z (4 months ago)
- Language: Dart
- Homepage:
- Size: 43.9 KB
- Stars: 11
- Watchers: 3
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# websockets
A platform-independent WebSocket library using the Dart async API.
This library defines a WebSocket interface very much like the one in `dart:io` that can be used when writing
platform-independent packages like API-wrappers.## Documentation
The documentation for this library can be found [on DartDocs](https://www.dartdocs.org/documentation/websockets/0.2.1/).
## Usage
Creating and using WebSockets with this library is easy, it works entirely the same as how the dart:io.WebSocket
class works:```dart
import "dart:io";
import "package:websockets/websockets.dart";main() async {
WebSocket ws = await WebSocket.connect("wss://echo.websocket.org");
ws.listen(print);
ws.add("test");
}
```### When developing platform-independent packages
Everything stays the same. The websockets import does not import `dart:io` or `dart:html`, so your code will run
on both platforms. One thing to remember is that the user of your library has to make an explicit import of either of
`dart:io` or `dart:html`.