mirror of
https://github.com/logos-storage/nim-json-rpc.git
synced 2026-01-07 08:03:07 +00:00
More proper client closing code
This commit is contained in:
parent
64d40d6c1a
commit
7a9d118929
@ -63,5 +63,7 @@ proc connect*(client: RpcSocketClient, address: string, port: Port) {.async.} =
|
||||
client.loop = processData(client)
|
||||
|
||||
method close*(client: RpcSocketClient) {.async.} =
|
||||
# TODO: Stop the processData loop
|
||||
await client.transport.closeWait()
|
||||
await client.loop.cancelAndWait()
|
||||
if not client.transport.isNil:
|
||||
client.transport.close()
|
||||
client.transport = nil
|
||||
|
||||
@ -78,5 +78,8 @@ proc connect*(client: RpcWebSocketClient, uri: string, headers: StringTableRef =
|
||||
client.loop = processData(client)
|
||||
|
||||
method close*(client: RpcWebSocketClient) {.async.} =
|
||||
await client.loop.cancelAndWait()
|
||||
if not client.transport.isNil:
|
||||
client.loop.cancel()
|
||||
client.transport.close()
|
||||
client.transport = nil
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user