mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-09 12:19:24 +00:00
comments
This commit is contained in:
parent
866b7c4e88
commit
39b99e6900
1 changed files with 4 additions and 2 deletions
|
@ -27,6 +27,8 @@ class JsonRPC {
|
||||||
void Function(List<int>)? _onData;
|
void Function(List<int>)? _onData;
|
||||||
void Function(Object, StackTrace)? _onError;
|
void Function(Object, StackTrace)? _onError;
|
||||||
|
|
||||||
|
List<dynamic>? _requestQueue; // TODO make Request model
|
||||||
|
|
||||||
Future<dynamic> request(String jsonRpcRequest) async {
|
Future<dynamic> request(String jsonRpcRequest) async {
|
||||||
final completer = Completer<dynamic>();
|
final completer = Completer<dynamic>();
|
||||||
final List<int> responseData = [];
|
final List<int> responseData = [];
|
||||||
|
@ -39,7 +41,7 @@ class JsonRPC {
|
||||||
if (data.last == 0x0A) {
|
if (data.last == 0x0A) {
|
||||||
try {
|
try {
|
||||||
final response = json.decode(String.fromCharCodes(responseData));
|
final response = json.decode(String.fromCharCodes(responseData));
|
||||||
completer.complete(response);
|
completer.complete(response); // TODO only complete on last chunk?
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
Logging.instance
|
Logging.instance
|
||||||
.log("JsonRPC json.decode: $e\n$s", level: LogLevel.Error);
|
.log("JsonRPC json.decode: $e\n$s", level: LogLevel.Error);
|
||||||
|
@ -89,7 +91,7 @@ class JsonRPC {
|
||||||
|
|
||||||
if (useSSL) {
|
if (useSSL) {
|
||||||
socket ??= await SecureSocket.connect(host, port,
|
socket ??= await SecureSocket.connect(host, port,
|
||||||
timeout: connectionTimeout, onBadCertificate: (_) => true);
|
timeout: connectionTimeout, onBadCertificate: (_) => true); // TODO do not automatically trust bad certificates
|
||||||
_subscription ??= socket!.listen(
|
_subscription ??= socket!.listen(
|
||||||
_onData,
|
_onData,
|
||||||
onError: _onError,
|
onError: _onError,
|
||||||
|
|
Loading…
Reference in a new issue