add proper example, update lints
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 98eebc5..77c5538 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,4 @@
-## 0.0.2
+## 1.0.0
- Internal cleanup.
diff --git a/example/README.md b/example/README.md
deleted file mode 100644
index 631fdad..0000000
--- a/example/README.md
+++ /dev/null
@@ -1 +0,0 @@
-The test folder provides a very basic usage example.
diff --git a/example/index.dart b/example/index.dart
new file mode 100644
index 0000000..afc1a49
--- /dev/null
+++ b/example/index.dart
@@ -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 the back.
+ channel.sink.add(s);
+ });
+}
diff --git a/example/server.dart b/example/server.dart
new file mode 100644
index 0000000..74439c9
--- /dev/null
+++ b/example/server.dart
@@ -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 connnects 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);
+ }
+}
diff --git a/lib/client/sse_client.dart b/lib/client/sse_client.dart
index d7e37ca..65bbbee 100644
--- a/lib/client/sse_client.dart
+++ b/lib/client/sse_client.dart
@@ -46,7 +46,8 @@
/// Add messages to this [StreamSink] to send them to the server.
///
- /// The message added to the sink has to be JSON encodable.
+ /// The message added to the sink has to be JSON encodable. Messages that fail
+ /// to encode will be logged through a [Logger].
@override
StreamSink<String> get sink => _outgoingController.sink;
diff --git a/pubspec.yaml b/pubspec.yaml
index 13c8db3..9e0487e 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: sse
-version: 0.0.1
+version: 1.0.0
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/sse
description: >-
diff --git a/test/sse_test.dart b/test/sse_test.dart
index cebde5c..d6e0445 100644
--- a/test/sse_test.dart
+++ b/test/sse_test.dart
@@ -44,7 +44,7 @@
});
test('Multiple clients can connect', () async {
- var connections = await handler.connections;
+ var connections = handler.connections;
await webdriver.get('http://localhost:${server.port}');
await connections.next;
await webdriver.get('http://localhost:${server.port}');
@@ -52,7 +52,7 @@
});
test('Routes data correctly', () async {
- var connections = await handler.connections;
+ var connections = handler.connections;
await webdriver.get('http://localhost:${server.port}');
var connectionA = await connections.next;
await webdriver.get('http://localhost:${server.port}');
diff --git a/tool/travis-setup.sh b/tool/travis-setup.sh
old mode 100644
new mode 100755