mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 20:54:33 +00:00
re-add mutex; release in doneHandler
This commit is contained in:
parent
3cb894e7c6
commit
535c400a69
1 changed files with 10 additions and 6 deletions
|
@ -2,7 +2,7 @@ import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
// import 'package:mutex/mutex.dart';
|
import 'package:mutex/mutex.dart';
|
||||||
|
|
||||||
import 'package:stackwallet/utilities/logger.dart';
|
import 'package:stackwallet/utilities/logger.dart';
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class JsonRPC {
|
||||||
Socket? socket;
|
Socket? socket;
|
||||||
StreamSubscription<Uint8List>? _subscription;
|
StreamSubscription<Uint8List>? _subscription;
|
||||||
|
|
||||||
// final m = Mutex();
|
final m = Mutex();
|
||||||
|
|
||||||
void Function(List<int>)? _onData;
|
void Function(List<int>)? _onData;
|
||||||
void Function(Object, StackTrace)? _onError;
|
void Function(Object, StackTrace)? _onError;
|
||||||
|
@ -79,15 +79,21 @@ class JsonRPC {
|
||||||
level: LogLevel.Info,
|
level: LogLevel.Info,
|
||||||
);
|
);
|
||||||
// socket?.destroy();
|
// socket?.destroy();
|
||||||
|
m.release();
|
||||||
// TODO is this all we need?
|
// TODO is this all we need?
|
||||||
}
|
}
|
||||||
|
|
||||||
if (socket != null) {
|
if (socket != null) {
|
||||||
// TODO check if the socket is valid, alive, connected, etc
|
// TODO check if the socket is valid, alive, connected, etc
|
||||||
|
} else {
|
||||||
|
Logging.instance.log(
|
||||||
|
"JsonRPC request: opening socket $host:$port",
|
||||||
|
level: LogLevel.Info,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// Do we need to check the subscription, too?
|
// Do we need to check the subscription, too?
|
||||||
|
|
||||||
// await m.acquire();
|
await m.acquire();
|
||||||
|
|
||||||
if (useSSL) {
|
if (useSSL) {
|
||||||
socket ??= await SecureSocket.connect(host, port,
|
socket ??= await SecureSocket.connect(host, port,
|
||||||
|
@ -115,12 +121,10 @@ class JsonRPC {
|
||||||
socket!.write('$jsonRpcRequest\r\n');
|
socket!.write('$jsonRpcRequest\r\n');
|
||||||
|
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
"JsonRPC errorHandler: wrote request $jsonRpcRequest to socket ${socket?.address}:${socket?.port}",
|
"JsonRPC request: wrote request $jsonRpcRequest to socket ${socket?.address}:${socket?.port}",
|
||||||
level: LogLevel.Info,
|
level: LogLevel.Info,
|
||||||
);
|
);
|
||||||
|
|
||||||
// m.release();
|
|
||||||
|
|
||||||
return completer.future;
|
return completer.future;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue