Skip to content

Commit

Permalink
Make isInKeepAlivePeriod as private (flutter#20)
Browse files Browse the repository at this point in the history
* Make isInKeepAlivePeriod as private

* fix doc

* fix markdown
  • Loading branch information
grouma authored Jan 6, 2020
1 parent 850b7bc commit a00e077
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 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
Expand All @@ -9,8 +16,8 @@

- Add retry logic.

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

## 2.1.2

Expand Down
8 changes: 4 additions & 4 deletions lib/src/server/sse_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SseConnection extends StreamChannelMixin<String> {
Timer _keepAliveTimer;

/// Whether this connection is currently in the KeepAlive timeout period.
bool get isInKeepAlivePeriod => _keepAliveTimer?.isActive ?? false;
bool get _isInKeepAlivePeriod => _keepAliveTimer?.isActive ?? false;

final _closedCompleter = Completer<void>();

Expand All @@ -60,7 +60,7 @@ class SseConnection extends StreamChannelMixin<String> {
while (await outgoingStreamQueue.hasNext) {
// If we're in a KeepAlive timeout, there's nowhere to send messages so
// wait a short period and check again.
if (isInKeepAlivePeriod) {
if (_isInKeepAlivePeriod) {
await Future.delayed(const Duration(milliseconds: 200));
continue;
}
Expand Down Expand Up @@ -105,7 +105,7 @@ class SseConnection extends StreamChannelMixin<String> {
if (_keepAlive == null) {
// Close immediately if we're not keeping alive.
_close();
} else if (!isInKeepAlivePeriod) {
} else if (!_isInKeepAlivePeriod) {
// Otherwise if we didn't already have an active timer, set a timer to
// close after the timeout period. If the connection comes back, this will
// be cancelled and all messages left in the queue tried again.
Expand Down Expand Up @@ -155,7 +155,7 @@ class SseHandler {
// Check if we already have a connection for this ID that is in the process
// of timing out (in which case we can reconnect it transparently).
if (_connections[clientId] != null &&
_connections[clientId].isInKeepAlivePeriod) {
_connections[clientId]._isInKeepAlivePeriod) {
_connections[clientId]._acceptReconnection(sink);
} else {
var connection = SseConnection(sink, keepAlive: _keepAlive);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sse
version: 3.1.0
version: 3.1.1
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/sse
description: >-
Expand Down

0 comments on commit a00e077

Please sign in to comment.