Skip to content

Commit

Permalink
Merge pull request #61 from itsparth/custom_dio
Browse files Browse the repository at this point in the history
Support for passing custom dio client
  • Loading branch information
faithoflifedev authored Oct 28, 2024
2 parents 6f30f54 + 0d2774b commit 4195eca
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions packages/easy_onvif/lib/src/onvif_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,24 @@ class Onvif with UiLoggy {
Onvif(
{required this.authInfo,
required LogOptions logOptions,
required LoggyPrinter printer})
required LoggyPrinter printer,
Dio? dio})
: _hostUri = (authInfo.host.startsWith('http')
? authInfo.host
: 'http://${authInfo.host}')
.parseUri {
Loggy.initLoggy(logPrinter: printer, logOptions: logOptions);

final dio = Dio(
BaseOptions(
connectTimeout: Duration(seconds: 20),
receiveTimeout: Duration(seconds: 10),
),
)..interceptors.add(LoggingInterceptors());
final dioClient = dio ??
Dio(
BaseOptions(
connectTimeout: Duration(seconds: 20),
receiveTimeout: Duration(seconds: 10),
),
)
..interceptors.add(LoggingInterceptors());

_transport = soap.Transport(dio: dio, authInfo: authInfo);
_transport = soap.Transport(dio: dioClient, authInfo: authInfo);

_deviceManagement = DeviceManagement(
transport: transport,
Expand All @@ -87,15 +90,17 @@ class Onvif with UiLoggy {
),
LoggyPrinter printer = const PrettyPrinter(
showColors: false,
)}) async {
),
Dio? dio}) async {
final onvif = Onvif(
authInfo: AuthInfo(
host: host,
username: username,
password: password,
),
logOptions: logOptions,
printer: printer);
printer: printer,
dio: dio);

await onvif.initialize();

Expand Down

0 comments on commit 4195eca

Please sign in to comment.