Skip to content

Commit

Permalink
Merge pull request #16 from takenet/feature/528184-remove-overlay
Browse files Browse the repository at this point in the history
fix: removed timeout error from sendFinishingSession
  • Loading branch information
githubdoandre authored Sep 21, 2023
2 parents 5960ede + e9ca983 commit 6b21ce9
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 80 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.25

* Fix ```sendFinishingSession``` method to not throw exception on timeout

## 0.0.24

* Fix connection when the WebSocket URI prefix has ```_``` (underscore).
Expand Down
7 changes: 3 additions & 4 deletions lib/src/protocol/client/client_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import '../node.dart';
import '../notification.dart';
import '../security/authentication.dart';
import '../session.dart';

import 'channel.dart';

/// Defines a communication channel between a node and a server.
Expand Down Expand Up @@ -63,7 +62,7 @@ class ClientChannel extends Channel {
}

/// Send a [Session] type [Envelope] with state [SessionState.finishing] to end the communication
Future<Session> sendFinishingSession() async {
Future<Session?> sendFinishingSession() async {
if (state != SessionState.established) {
throw Exception('Cannot finish a session in the $state state');
}
Expand All @@ -84,10 +83,10 @@ class ClientChannel extends Channel {
return c.future;
}),
Future(() {
final c = Completer<Session>();
final c = Completer<Session?>();

Future.delayed(const Duration(milliseconds: 6000), () {
return c.completeError('Timeout reached - sendFinishingSession');
return c.complete();
});

return c.future;
Expand Down
12 changes: 6 additions & 6 deletions lib/src/protocol/network/web_socket_transport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class WebSocketTransport implements Transport {
final response = jsonDecode(data);

logger.info(
'Envelope received: $uri \n' + prettyJson(response, indent: 2));
'Envelope received: $uri \n${prettyJson(response, indent: 2)}');

onEnvelope?.add(response);
},
Expand Down Expand Up @@ -134,7 +134,7 @@ class WebSocketTransport implements Transport {
socket?.add(encode);

logger
.info('Envelope send: \n' + prettyJson(jsonDecode(encode), indent: 2));
.info('Envelope send: \n${prettyJson(jsonDecode(encode), indent: 2)}');
}

void ensureSocketOpen() {
Expand All @@ -147,16 +147,16 @@ class WebSocketTransport implements Transport {
get onEnvelope => onEnvelopeStream;

@override
set onEnvelope(StreamController<Map<String, dynamic>>? _onEnvelope) {
onEnvelopeStream = _onEnvelope;
set onEnvelope(StreamController<Map<String, dynamic>>? onEnvelope) {
onEnvelopeStream = onEnvelope;
}

@override
get onConnectionDone => onConnectionDoneStream;

@override
set onConnectionDone(StreamController<bool>? _onConnectionDone) {
onConnectionDoneStream = _onConnectionDone;
set onConnectionDone(StreamController<bool>? onConnectionDone) {
onConnectionDoneStream = onConnectionDone;
}

Future<List<int>> _getKeyBytes() async {
Expand Down
8 changes: 5 additions & 3 deletions lib/src/protocol/security/external_authentication.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../extensions/string.extension.dart';
import 'authentication.dart';
import 'enums/authentication_scheme.enum.dart';
import '../extensions/string.extension.dart';

/// Defines a external authentication scheme, that uses third-party validation.
class ExternalAuthentication extends Authentication {
Expand All @@ -14,8 +14,10 @@ class ExternalAuthentication extends Authentication {
String? issuer;

/// Initializes a new instance of the [ExternalAuthentication] class.
ExternalAuthentication({this.token, this.issuer})
: super(AuthenticationScheme.external);
ExternalAuthentication({
this.token,
this.issuer,
}) : super(AuthenticationScheme.external);

/// Set a plain token to a base64 representation
void setToBase64Token(final String? password) {
Expand Down
6 changes: 3 additions & 3 deletions lib/src/protocol/security/key_authentication.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../extensions/string.extension.dart';
import 'authentication.dart';
import 'enums/authentication_scheme.enum.dart';
import '../extensions/string.extension.dart';

/// Defines a authentication scheme that uses a key for authentication.
/// Should be used only with encrypted sessions.
Expand All @@ -14,8 +14,8 @@ class KeyAuthentication extends Authentication {
KeyAuthentication({this.key}) : super(AuthenticationScheme.key);

/// Set a plain key to a Base64 representation.
void setToBase64Key(final String? _key) {
key = _key?.toBase64();
void setToBase64Key(final String? key) {
this.key = key?.toBase64();
}

/// Gets the plain key decoded from the Base64 representation.
Expand Down
6 changes: 3 additions & 3 deletions lib/src/protocol/security/plain_authentication.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../extensions/string.extension.dart';
import 'authentication.dart';
import 'enums/authentication_scheme.enum.dart';
import '../extensions/string.extension.dart';

/// Defines a plain authentication scheme, that uses a password for authentication.
/// Should be used only with encrypted sessions.
Expand All @@ -14,8 +14,8 @@ class PlainAuthentication extends Authentication {
PlainAuthentication({this.password}) : super(AuthenticationScheme.plain);

/// Set a plain password to a Base64 representation
void setToBase64Password(final String? _password) {
password = _password?.toBase64();
void setToBase64Password(final String? password) {
this.password = password?.toBase64();
}

/// Gets the plain password decoded from the Base64 representation
Expand Down
Loading

0 comments on commit 6b21ce9

Please sign in to comment.