mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-22 02:24:30 +00:00
reuse socket var where possible
This commit is contained in:
parent
2428dd7d12
commit
281a04654c
1 changed files with 7 additions and 12 deletions
|
@ -53,20 +53,15 @@ class JsonRPC {
|
|||
}
|
||||
|
||||
if (useSSL) {
|
||||
await SecureSocket.connect(host, port,
|
||||
socket ??= await SecureSocket.connect(host, port,
|
||||
timeout: connectionTimeout,
|
||||
onBadCertificate: (_) => true).then((Socket sock) {
|
||||
socket = sock;
|
||||
socket?.listen(dataHandler,
|
||||
onBadCertificate: (_) => true);
|
||||
socket!.listen(dataHandler,
|
||||
onError: errorHandler, onDone: doneHandler, cancelOnError: true);
|
||||
});
|
||||
} else {
|
||||
await Socket.connect(host, port, timeout: connectionTimeout)
|
||||
.then((Socket sock) {
|
||||
socket = sock;
|
||||
socket?.listen(dataHandler,
|
||||
socket ??= await Socket.connect(host, port, timeout: connectionTimeout);
|
||||
socket!.listen(dataHandler,
|
||||
onError: errorHandler, onDone: doneHandler, cancelOnError: true);
|
||||
});
|
||||
}
|
||||
|
||||
socket?.write('$jsonRpcRequest\r\n');
|
||||
|
|
Loading…
Reference in a new issue