From 9d08cae867167f28404fc236c266077cb7ef8c0d Mon Sep 17 00:00:00 2001 From: Muzzammil Shahid Date: Tue, 30 Apr 2024 18:29:25 +0500 Subject: [PATCH] Export session and client --- lib/exports.dart | 3 +++ lib/src/client.dart | 11 +++++++---- lib/src/helpers.dart | 2 +- lib/src/wsjoiner.dart | 9 ++++++--- lib/wamp_session.dart | 1 - 5 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 lib/exports.dart delete mode 100644 lib/wamp_session.dart diff --git a/lib/exports.dart b/lib/exports.dart new file mode 100644 index 0000000..cd766ca --- /dev/null +++ b/lib/exports.dart @@ -0,0 +1,3 @@ +export "src/client.dart" show Client; +export "src/session.dart" show Session; +export "src/types.dart" show Registration, Subscription; diff --git a/lib/src/client.dart b/lib/src/client.dart index 774e14e..74ab3d0 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -5,13 +5,16 @@ import "package:wampproto/auth.dart"; import "package:wampproto/serializers.dart"; class Client { - Client(this._authenticator, this._serializer); + Client({IClientAuthenticator? authenticator, Serializer? serializer}) { + _authenticator = authenticator; + _serializer = serializer; + } - final IClientAuthenticator _authenticator; - final Serializer _serializer; + IClientAuthenticator? _authenticator; + Serializer? _serializer; Future connect(String url, String realm) async { - WAMPSessionJoiner joiner = WAMPSessionJoiner(_authenticator, serializer: _serializer); + WAMPSessionJoiner joiner = WAMPSessionJoiner(authenticator: _authenticator, serializer: _serializer); BaseSession baseSession = await joiner.join(url, realm); return Session(baseSession); diff --git a/lib/src/helpers.dart b/lib/src/helpers.dart index fadad52..e0becb6 100644 --- a/lib/src/helpers.dart +++ b/lib/src/helpers.dart @@ -1,4 +1,4 @@ -import "package:wamp/wamp_session.dart"; +import "package:wamp/src/wsjoiner.dart"; import "package:wampproto/messages.dart"; import "package:wampproto/serializers.dart"; diff --git a/lib/src/wsjoiner.dart b/lib/src/wsjoiner.dart index f32301f..d04e8e7 100644 --- a/lib/src/wsjoiner.dart +++ b/lib/src/wsjoiner.dart @@ -9,14 +9,17 @@ import "package:wampproto/joiner.dart"; import "package:wampproto/serializers.dart"; class WAMPSessionJoiner { - WAMPSessionJoiner(this._authenticator, {Serializer? serializer}) : _serializer = serializer ?? JSONSerializer(); + WAMPSessionJoiner({IClientAuthenticator? authenticator, Serializer? serializer}) { + _serializer = serializer ?? JSONSerializer(); + _authenticator = authenticator; + } static const String jsonSubProtocol = "wamp.2.json"; static const String cborSubProtocol = "wamp.2.cbor"; static const String msgpackSubProtocol = "wamp.2.msgpack"; - final IClientAuthenticator _authenticator; - final Serializer _serializer; + IClientAuthenticator? _authenticator; + late Serializer _serializer; Future join(String uri, String realm) async { // ignore: close_sinks diff --git a/lib/wamp_session.dart b/lib/wamp_session.dart deleted file mode 100644 index 9c46ab6..0000000 --- a/lib/wamp_session.dart +++ /dev/null @@ -1 +0,0 @@ -export "src/wsjoiner.dart" show WAMPSessionJoiner;