Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge package:sse #1264

Merged
merged 121 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 120 commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
89fc0d9
Initial commit
grouma Feb 5, 2019
2360adc
Cleanup
grouma Feb 15, 2019
35e28a1
make travis.sh executable
grouma Feb 15, 2019
70ad296
add proper example, update lints
grouma Feb 15, 2019
6d7ced4
update travis config
grouma Feb 15, 2019
210b0da
Merge pull request dart-lang/sse#2 from dart-lang/cleanup
grouma Feb 15, 2019
e7170f7
remove whitespace
grouma Feb 15, 2019
313d2f4
fix typo
grouma Feb 15, 2019
a54125b
Merge pull request dart-lang/sse#3 from dart-lang/whitespace
grouma Feb 19, 2019
ea29f19
Better close logic
grouma Mar 9, 2019
8db9088
add test
grouma Mar 9, 2019
978fad5
update pubspec
grouma Mar 9, 2019
f6f9d64
use a map
grouma Mar 9, 2019
26ad243
fix typo add test
grouma Mar 9, 2019
bf44a34
update chromedriver
grouma Mar 9, 2019
6eda946
even later
grouma Mar 9, 2019
651ed2e
make local testing better
grouma Mar 9, 2019
1122493
maybe this will fix it?
grouma Mar 9, 2019
f17cdb6
remove connections faster
grouma Mar 9, 2019
4af6683
don't expose close
grouma Mar 11, 2019
2198d44
null aware
grouma Mar 11, 2019
c0a5bc4
use stable chrome
grouma Mar 11, 2019
6f92177
Merge pull request dart-lang/sse#4 from dart-lang/close-cleanup
grouma Mar 11, 2019
ab6adf0
update to uuid version 2.0
jakemac53 Mar 20, 2019
95a3af2
Merge pull request dart-lang/sse#6 from dart-lang/uuid-2.0
grouma Mar 20, 2019
85f6bc2
Enable and fix lints
kevmoo Apr 20, 2019
8041be6
Support the latest pkg:stream_channel
kevmoo Apr 20, 2019
2daec51
Test on oldest supported SDK, bump SDK to 2.1.0
kevmoo Apr 20, 2019
256cef6
prepare for release
kevmoo Apr 26, 2019
b438bbd
Download the chromedriver version based on the chrome version (dart-l…
jakemac53 Aug 6, 2019
13beef7
Fixed race condition for posting messages. (dart-lang/sse#11)
Aug 28, 2019
8c4b2ac
prep to publish (dart-lang/sse#12)
grouma Sep 4, 2019
b6f290d
Support Firefox (dart-lang/sse#13)
grouma Sep 11, 2019
3bdc3af
Use proper header delimiter (dart-lang/sse#14)
grouma Sep 12, 2019
057fb71
Remove package:http dependency (dart-lang/sse#15)
grouma Oct 14, 2019
e82e5c7
Add retry logic (dart-lang/sse#17)
grouma Nov 15, 2019
2f89785
Support transparent reconnects on the server (dart-lang/sse#19)
DanTup Jan 6, 2020
3ee4321
Make isInKeepAlivePeriod as private (dart-lang/sse#20)
grouma Jan 6, 2020
1c0d3c2
Remove author field
grouma Jan 9, 2020
5b16284
Proper close on error (dart-lang/sse#21)
grouma Feb 1, 2020
64c5022
Re-expose the keep-alive flag to consumers (dart-lang/sse#22)
DanTup Feb 26, 2020
d681e11
Fix keepAlive reconnection (dart-lang/sse#23)
grouma Mar 2, 2020
88752ca
Fix state error with keep alive (dart-lang/sse#24)
grouma Apr 7, 2020
668b92b
Add onClose (dart-lang/sse#25)
grouma Apr 9, 2020
c882ac6
Ensure sink.done correctly fires (dart-lang/sse#26)
grouma Apr 9, 2020
51ef2d5
Support shutting down the handler ignoring any keepAlive periods (dar…
DanTup Apr 23, 2020
e04ef09
Improve performance (dart-lang/sse#31)
grouma Oct 27, 2020
c50d084
Drop dependency on package:uuid (dart-lang/sse#32)
natebosch Nov 16, 2020
9648a35
Prep to publish (dart-lang/sse#35)
grouma Jan 22, 2021
8ddfc20
Update documentation (dart-lang/sse#37)
grouma Feb 5, 2021
b5a3319
Deprecate onConnect (dart-lang/sse#36)
grouma Feb 5, 2021
bd1ecfe
Add onConnected (dart-lang/sse#39)
grouma Feb 8, 2021
2b9ddda
Prevent onDone error (dart-lang/sse#40)
grouma Feb 9, 2021
5737af1
Complete `onConnected` with error if connection fails to open (dart-l…
leonsenft Feb 11, 2021
64e56f7
update to the latest shelf and remove dead code (dart-lang/sse#43)
jakemac53 Feb 26, 2021
a751de9
prep to publish (dart-lang/sse#45)
grouma Mar 17, 2021
ebdb7ac
Update LICENSE (dart-lang/sse#46)
franklinyow Apr 6, 2021
ac23979
Migrate to null safety (dart-lang/sse#50)
grouma May 11, 2021
de3ebfc
Buffer concurrent requests (dart-lang/sse#51)
grouma Jun 5, 2021
cce1b49
Use drain over toList when values are ignored (dart-lang/sse#52)
natebosch Jun 7, 2021
becabeb
Move from travis to github actions (dart-lang/sse#55)
natebosch Aug 31, 2021
15b1f52
Clarify package intent (dart-lang/sse#57)
grouma Sep 1, 2021
5b74b26
keepAlive for SocketExceptions (dart-lang/sse#58)
grouma Sep 16, 2021
d15226e
Switch to using package:lints (dart-lang/sse#59)
devoncarew Apr 20, 2022
6afa139
populate the pubspec repository field (dart-lang/sse#60)
devoncarew May 3, 2022
316b55d
Remove deprecated experimental invariant_booleans lint rule (dart-lan…
srawlins Jul 25, 2022
b93f86e
update ci; prep for publishing (dart-lang/sse#64)
devoncarew Oct 14, 2022
1f13de4
Use Fetch API in SSE Client (dart-lang/sse#66)
elliette Nov 23, 2022
adc1517
Add optional `debugKey` parameter to SSE client (dart-lang/sse#67)
elliette Nov 23, 2022
4151abe
Format markdown files (dart-lang/sse#68)
elliette Nov 24, 2022
ce179a2
Fix Fetch credentials (dart-lang/sse#69)
elliette Nov 29, 2022
4839881
Update `package:sse` to `4.1.2`(dart-lang/sse#70)
elliette Dec 13, 2022
a0e1f38
Add `package:js` to dependencies (dart-lang/sse#71)
elliette Dec 14, 2022
8c8e7d3
Bump nanasess/setup-chromedriver from 1.0.5 to 1.1.0 (dart-lang/sse#65)
dependabot[bot] Dec 28, 2022
82cc71d
Bump actions/checkout from 3.1.0 to 3.2.0 (dart-lang/sse#73)
dependabot[bot] Jan 3, 2023
2435e2e
Migrate from no-implicit-casts to strict-casts (dart-lang/sse#74)
srawlins Jan 10, 2023
3b38ba7
Fix deprecated import to webdriver library (dart-lang/sse#76)
kevmoo Jan 26, 2023
1eff5da
Bump dart-lang/setup-dart from 1.3 to 1.4 (dart-lang/sse#77)
dependabot[bot] Feb 1, 2023
2fa9094
Bump actions/checkout from 3.2.0 to 3.3.0 (dart-lang/sse#78)
dependabot[bot] Feb 1, 2023
ec3ad5c
Bump nanasess/setup-chromedriver from 1.1.0 to 2.0.0 (dart-lang/sse#81)
dependabot[bot] Apr 3, 2023
2716ae2
Bump actions/checkout from 3.3.0 to 3.5.0 (dart-lang/sse#80)
dependabot[bot] Apr 3, 2023
593f686
Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/sse#79)
dependabot[bot] Apr 3, 2023
79e6d93
Require Dart 2.19, bump lints (dart-lang/sse#82)
kevmoo Apr 10, 2023
fabfd94
Bump actions/checkout from 3.5.0 to 3.5.2 (dart-lang/sse#83)
dependabot[bot] May 8, 2023
a5220f5
blast_repo fixes (dart-lang/sse#84)
devoncarew May 19, 2023
ab4f757
Bump actions/checkout from 3.5.2 to 3.5.3 (dart-lang/sse#85)
dependabot[bot] Jul 1, 2023
972c238
Bump nanasess/setup-chromedriver from 2.0.0 to 2.1.1 (dart-lang/sse#86)
dependabot[bot] Aug 1, 2023
4d38494
Bump nanasess/setup-chromedriver from 2.1.1 to 2.2.0 (dart-lang/sse#88)
dependabot[bot] Sep 1, 2023
b217d29
Bump actions/checkout from 3.5.3 to 3.6.0 (dart-lang/sse#87)
dependabot[bot] Sep 1, 2023
126f752
Bump actions/checkout from 3.6.0 to 4.1.0 (dart-lang/sse#89)
dependabot[bot] Oct 1, 2023
b35ff99
Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (dart-lang/sse#90)
dependabot[bot] Oct 3, 2023
3f50850
Enable and fix latest lints (dart-lang/sse#91)
kevmoo Oct 13, 2023
340710f
Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (dart-lang/sse#93)
dependabot[bot] Nov 1, 2023
f84f02a
Bump nanasess/setup-chromedriver from 2.2.0 to 2.2.1 (dart-lang/sse#94)
dependabot[bot] Nov 1, 2023
7770709
Bump actions/checkout from 4.1.0 to 4.1.1 (dart-lang/sse#95)
dependabot[bot] Nov 1, 2023
10d062a
Require Dart 3.2, use pkg:web (dart-lang/sse#92)
kevmoo Nov 15, 2023
fa2c621
Fix incorrect cast causing wasm failure, prepare v4.1.4 (dart-lang/ss…
kevmoo Nov 22, 2023
9237f53
Drop unneeded dep on pkg:test (dart-lang/sse#98)
kevmoo Dec 1, 2023
72387ba
Bump nanasess/setup-chromedriver (dart-lang/sse#99)
dependabot[bot] Dec 1, 2023
0e0942a
Bump dart-lang/setup-dart from 1.6.0 to 1.6.2 (dart-lang/sse#101)
dependabot[bot] Feb 1, 2024
5c2e923
Make `SseConnection` extend `StreamChannelMixin<String>` (dart-lang/s…
Feb 9, 2024
60c2d50
Support the latest pkg:web, require Dart 3.3 (dart-lang/sse#103)
kevmoo Feb 17, 2024
7fac9cd
blast_repo fixes (dart-lang/sse#104)
kevmoo Feb 20, 2024
508636b
Prepare release of v4.1.5 (dart-lang/sse#105)
kevmoo Feb 29, 2024
b2916dc
Bump actions/checkout from 4.1.1 to 4.1.2 (dart-lang/sse#106)
dependabot[bot] Apr 1, 2024
47e5bcd
Bump dart-lang/setup-dart from 1.6.2 to 1.6.4 (dart-lang/sse#107)
dependabot[bot] May 1, 2024
10c856b
Bump actions/checkout from 4.1.2 to 4.1.4 (dart-lang/sse#108)
dependabot[bot] May 1, 2024
604897f
blast_repo fixes (dart-lang/sse#109)
devoncarew May 13, 2024
6c5b63e
Bump actions/checkout from 4.1.4 to 4.1.5 in the github-actions group…
dependabot[bot] May 13, 2024
64c2389
Bump actions/checkout from 4.1.5 to 4.1.6 in the github-actions group…
dependabot[bot] Jun 1, 2024
d214560
Bump the github-actions group with 2 updates (dart-lang/sse#112)
dependabot[bot] Jul 1, 2024
d5acd69
Add support for package:web v1.0.0 (dart-lang/sse#113)
srujzs Jul 16, 2024
8c64cb6
Bump to latest lints (dart-lang/sse#114)
kevmoo Jul 17, 2024
3ec9b8b
blast_repo fixes (dart-lang/sse#117)
kevmoo Oct 29, 2024
18c2a7b
Bump actions/checkout from 4.1.7 to 4.2.0 in the github-actions group…
dependabot[bot] Oct 29, 2024
261036c
Bump actions/checkout from 4.2.0 to 4.2.2 in the github-actions group…
dependabot[bot] Nov 4, 2024
32f019e
Bump dart-lang/setup-dart in the github-actions group (dart-lang/sse#…
dependabot[bot] Dec 2, 2024
985ce59
Merge package:sse into the tools monorepo
mosuem Dec 10, 2024
969af62
Add issue template and other fixes
mosuem Dec 10, 2024
597d290
merge fixes
mosuem Dec 10, 2024
456e9aa
Merge branch 'main' into merge-sse-package
mosuem Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/sse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
name: "package:sse"
about: "Create a bug or file a feature request against package:sse."
labels: "package:sse"
---
4 changes: 4 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
- changed-files:
- any-glob-to-any-file: 'pkgs/source_map_stack_trace/**'

'package:sse':
- changed-files:
- any-glob-to-any-file: 'pkgs/sse/**'

'package:unified_analytics':
- changed-files:
- any-glob-to-any-file: 'pkgs/unified_analytics/**'
73 changes: 73 additions & 0 deletions .github/workflows/sse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: package:sse

on:
# Run on PRs and pushes to the default branch.
push:
branches: [ main ]
paths:
- '.github/workflows/sse.yaml'
- 'pkgs/sse/**'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/sse.yaml'
- 'pkgs/sse/**'
schedule:
- cron: "0 0 * * 0"

env:
PUB_ENVIRONMENT: bot.github


defaults:
run:
working-directory: pkgs/sse/

jobs:
# Check code formatting and static analysis on a single OS (linux)
# against Dart dev.
analyze:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: [dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- id: install
name: Install dependencies
run: dart pub get
- name: Check formatting
run: dart format --output=none --set-exit-if-changed .
if: always() && steps.install.outcome == 'success'
- name: Analyze code
run: dart analyze --fatal-infos
if: always() && steps.install.outcome == 'success'

# Run tests on a matrix consisting of two dimensions:
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
# 2. release channel: dev
test:
needs: analyze
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: [3.3, dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- uses: nanasess/setup-chromedriver@42cc2998329f041de87dc3cfa33a930eacd57eaa
- id: install
name: Install dependencies
run: dart pub get
- name: Run VM tests
run: dart test --platform vm --test-randomize-ordering-seed=random -j 1
if: always() && steps.install.outcome == 'success'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ don't naturally belong to other topic monorepos (like
| [mime](pkgs/mime/) | Utilities for handling media (MIME) types, including determining a type from a file extension and file contents. | [![package issues](https://img.shields.io/badge/package:mime-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Amime) | [![pub package](https://img.shields.io/pub/v/mime.svg)](https://pub.dev/packages/mime) |
| [oauth2](pkgs/oauth2/) | A client library for authenticating with a remote service via OAuth2 on behalf of a user, and making authorized HTTP requests with the user's OAuth2 credentials. | [![package issues](https://img.shields.io/badge/package:oauth2-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aoauth2) | [![pub package](https://img.shields.io/pub/v/oauth2.svg)](https://pub.dev/packages/oauth2) |
| [source_map_stack_trace](pkgs/source_map_stack_trace/) | A package for applying source maps to stack traces. | [![package issues](https://img.shields.io/badge/package:source_map_stack_trace-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_map_stack_trace) | [![pub package](https://img.shields.io/pub/v/source_map_stack_trace.svg)](https://pub.dev/packages/source_map_stack_trace) |
| [sse](pkgs/sse/) | Provides client and server functionality for setting up bi-directional communication through Server Sent Events (SSE) and corresponding POST requests. | [![package issues](https://img.shields.io/badge/package:sse-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asse) | [![pub package](https://img.shields.io/pub/v/sse.svg)](https://pub.dev/packages/sse) |
| [unified_analytics](pkgs/unified_analytics/) | A package for logging analytics for all Dart and Flutter related tooling to Google Analytics. | [![package issues](https://img.shields.io/badge/package:unified_analytics-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aunified_analytics) | [![pub package](https://img.shields.io/pub/v/unified_analytics.svg)](https://pub.dev/packages/unified_analytics) |

## Publishing automation
Expand Down
3 changes: 3 additions & 0 deletions pkgs/sse/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.dart_tool
pubspec.lock
test/web/index.dart.js.deps
6 changes: 6 additions & 0 deletions pkgs/sse/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Below is a list of people and organizations that have contributed
# to the Dart project. Names should be added to the list like so:
#
# Name/Organization <email address>

Google Inc.
178 changes: 178 additions & 0 deletions pkgs/sse/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
## 4.1.7

- Move to `dart-lang/tools` monorepo.

## 4.1.6

- Require package `web: '>=0.5.0 <2.0.0'`.

## 4.1.5

- Drop unneeded dependency on `package:js`.
- Update the minimum Dart SDK version to `3.3.0`.
- Support the latest `package:web`.

## 4.1.4

- Fix incorrect cast causing failure with `dart2wasm`.

## 4.1.3

- Update the minimum Dart SDK version to `3.2.0`.

## 4.1.2

- Send `fetch` requests instead of `XHR` requests.
- Add an optional `debugKey` parameter to `SseClient` to include in logging.
- Add a dependency on `package:js`.
- Update the minimum Dart SDK version to `2.16.0`.

## 4.1.1

- Apply `keepAlive` logic to `SocketException`s.
- Switch from using `package:pedantic` to `package:lints`
- Rev the minimum required SDK to 2.15.
- Populate the pubspec `repository` field.

## 4.1.0

- Limit the number of concurrent requests to prevent Chrome from automatically
dropping them on the floor.

## 4.0.0

- Support null safety.

## 3.8.3

- Require the latest shelf and remove dead code.

## 3.8.2

- Complete `onConnected` with an error if the `SseClient` receives an error
before the connection is successfully opened.

## 3.8.1

- Fix an issue where closing the `SseConnection` stream would result in an
error.

## 3.8.0

- Add `onConnected` to replace `onOpen`.
- Fix an issue where failed requests would not add a `done` event to the
connection `sink`.

## 3.7.0

- Deprecate the client's `onOpen` getter. Messages will now be buffered until a
connection is established.

## 3.6.1

- Drop dependency on `package:uuid`.

## 3.6.0

- Improve performance by buffering out of order messages in the server instead
of the client.

\*\* Note \*\* This is not modelled as a breaking change as the server can
handle messages from older clients. However, clients should be using the latest
server if they require order guarantees.

## 3.5.0

- Add new `shutdown` methods on `SseHandler` and `SseConnection` to allow
closing connections immediately, ignoring any keep-alive periods.

## 3.4.0

- Remove `onClose` from `SseConnection` and ensure the corresponding
`sink.close` correctly fires.

## 3.3.0

- Add an `onClose` event to the `SseConnection`. This allows consumers to listen
to this event in lue of `sseConnection.sink.done` as that is not guaranteed to
fire.

## 3.2.2

- Fix an issue where `keepAlive` may cause state errors when attempting to send
messages on a closed stream.

## 3.2.1

- Fix an issue where `keepAlive` would only allow a single reconnection.

## 3.2.0

- Re-expose `isInKeepAlivePeriod` flag on `SseConnection`. This flag will be
`true` when a connection has been dropped and is in the keep-alive period
waiting for a client to reconnect.

## 3.1.2

- Fix an issue where the `SseClient` would not send a `done` event when there
was an error with the SSE connection.

## 3.1.1

- Make `isInKeepAlive` on `SseConnection` private.

**Note that this is a breaking change but in actuality no one should be
depending on this API.**

## 3.1.0

- Add optional `keepAlive` parameter to the `SseHandler`. If `keepAlive` is
supplied, the connection will remain active for this period after a disconnect
and can be reconnected transparently. If there is no reconnect within that
period, the connection will be closed normally.

## 3.0.0

- Add retry logic.

**Possible Breaking Change Error messages may now be delayed up to 5 seconds in
the client.**

## 2.1.2

- Remove `package:http` dependency.

## 2.1.1

- Use proper headers delimiter.

## 2.1.0

- Support Firefox.

## 2.0.3

- Fix an issue where messages could come out of order.

## 2.0.2

- Support the latest `package:stream_channel`.
- Require Dart SDK `>=2.1.0 <3.0.0`.

## 2.0.1

- Update to `package:uuid` version 2.0.

## 2.0.0

- No longer expose `close` and `onClose` on an `SseConnection`. This is simply
handled by the underlying `stream` / `sink`.
- Fix a bug where resources of the `SseConnection` were not properly closed.

## 1.0.0

- Internal cleanup.

## 0.0.1

- Initial commit.
27 changes: 27 additions & 0 deletions pkgs/sse/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2019, the Dart project authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 changes: 14 additions & 0 deletions pkgs/sse/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[![Build Status](https://github.com/dart-lang/tools/actions/workflows/sse.yaml/badge.svg)](https://github.com/dart-lang/tools/actions/workflows/sse.yaml)
[![pub package](https://img.shields.io/pub/v/sse.svg)](https://pub.dev/packages/sse)
[![package publisher](https://img.shields.io/pub/publisher/sse.svg)](https://pub.dev/packages/sse/publisher)

This package provides support for bi-directional communication through Server
Sent Events and corresponding POST requests.

This package is not intended to be a general purpose SSE package, but instead is
a bidirectional protocol for use when Websockets are unavailable. That is, both
the client and the server expose a `sink` and `stream` on which to send and
receive messages respectively.

Both the server and client have implicit assumptions on each other and therefore
a client from this package must be paired with a server from this package.
13 changes: 13 additions & 0 deletions pkgs/sse/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://dart.dev/guides/language/analysis-options
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
language:
strict-casts: true

linter:
rules:
- avoid_unused_constructor_parameters
- cancel_subscriptions
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
15 changes: 15 additions & 0 deletions pkgs/sse/example/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:sse/client/sse_client.dart';

/// A basic example which should be used in a browser that supports SSE.
void main() {
var channel = SseClient('/sseHandler');

channel.stream.listen((s) {
// Listen for messages and send them back.
channel.sink.add(s);
});
}
21 changes: 21 additions & 0 deletions pkgs/sse/example/server.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:shelf/shelf_io.dart' as io;
import 'package:sse/server/sse_handler.dart';

/// A basic server which sets up an SSE handler.
///
/// When a client connects it will send a simple message and print the
/// response.
void main() async {
var handler = SseHandler(Uri.parse('/sseHandler'));
await io.serve(handler.handler, 'localhost', 0);
var connections = handler.connections;
while (await connections.hasNext) {
var connection = await connections.next;
connection.sink.add('foo');
connection.stream.listen(print);
}
}
Loading
Loading