-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmqtt_client_factory.dart
More file actions
51 lines (41 loc) · 1.36 KB
/
mqtt_client_factory.dart
File metadata and controls
51 lines (41 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2022 Contributors to the Eclipse Foundation. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// SPDX-License-Identifier: BSD-3-Clause
import "../../core.dart";
import "constants.dart";
import "mqtt_client.dart";
import "mqtt_config.dart";
/// [ProtocolClientFactory] for creating [MqttClient]s.
final class MqttClientFactory implements ProtocolClientFactory {
/// Instatiates a new [MqttClientFactory].
MqttClientFactory({
MqttConfig? mqttConfig,
AsyncClientSecurityCallback<BasicCredentials>? basicCredentialsCallback,
}) : _mqttConfig = mqttConfig,
_basicCredentialsCallback = basicCredentialsCallback;
final MqttConfig? _mqttConfig;
final AsyncClientSecurityCallback<BasicCredentials>?
_basicCredentialsCallback;
@override
Future<ProtocolClient> createClient() async => MqttClient(
mqttConfig: _mqttConfig,
basicCredentialsCallback: _basicCredentialsCallback,
);
@override
bool destroy() {
return true;
}
@override
bool init() {
return true;
}
@override
Set<String> get schemes => {mqttUriScheme, mqttSecureUriScheme};
@override
bool supportsOperation(OperationType operationType, String? subprotocol) {
// MQTT client does not support any subprotocols
return subprotocol == null;
}
}