[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet-nim] 02/02: let's try out ports and channels
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet-nim] 02/02: let's try out ports and channels |
Date: |
Sun, 29 Jul 2018 20:02:10 +0200 |
This is an automated email from the git hooks/post-receive script.
lurchi pushed a commit to branch master
in repository gnunet-nim.
commit 4b7a974c085cf6791c12e9970439cced5a3d1c53
Author: lurchi <address@hidden>
AuthorDate: Sun Jul 29 20:01:49 2018 +0200
let's try out ports and channels
---
asynccadet.nim | 1 +
gnunet_nim.nim | 10 ++++++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/asynccadet.nim b/asynccadet.nim
index 171382a..1d4366a 100644
--- a/asynccadet.nim
+++ b/asynccadet.nim
@@ -100,6 +100,7 @@ proc openPort*(handle: var CadetHandle, port: string): ref
CadetPort =
proc closePort*(handle: var CadetHandle, port: ref CadetPort) =
GNUNET_CADET_close_port(port.handle)
+ port.channels.complete()
handle.openPorts.delete(handle.openPorts.find(port))
proc createChannel*(handle: CadetHandle, peer: string, port: string):
CadetChannel =
diff --git a/gnunet_nim.nim b/gnunet_nim.nim
index bfeff69..65cf0a6 100644
--- a/gnunet_nim.nim
+++ b/gnunet_nim.nim
@@ -7,10 +7,12 @@ proc firstTask(gnunetApp: ref GnunetApplication) {.async.} =
var cadet = await gnunetApp.connectCadet()
echo "connected"
let port = cadet.openPort("test")
- let channel = await port.channels.read()
- echo "incoming connection!"
- let message = await channel.messages.read()
- echo "got message: ", message
+ let (finished, channel) = await port.channels.read()
+ if not finished:
+ echo "incoming connection!"
+ let (finished, message) = await channel.messages.read()
+ if not finished:
+ echo "got message: ", message
cadet.disconnect()
echo "disconnected"
--
To stop receiving notification emails like this one, please contact
address@hidden