[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet-nim] 54/61: try out nimbox
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet-nim] 54/61: try out nimbox |
Date: |
Sat, 13 Apr 2019 13:36:29 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnunet-nim.
commit 9bb383003464cbe6e0fe0abc2a9a060bbaf70be6
Author: lurchi <address@hidden>
AuthorDate: Sun Aug 26 12:29:29 2018 +0200
try out nimbox
---
examples/groupchat.nim | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/examples/groupchat.nim b/examples/groupchat.nim
index 93d4323..7b3ac82 100644
--- a/examples/groupchat.nim
+++ b/examples/groupchat.nim
@@ -1,5 +1,5 @@
import ../gnunet_application, ../asynccadet, ../gnunet_utils
-import asyncdispatch, asyncfile, parseopt, strutils, sequtils, times, os
+import asyncdispatch, asyncfile, parseopt, strutils, sequtils, times, os,
nimbox
type Chat = object
channels: seq[ref CadetChannel]
@@ -28,10 +28,17 @@ proc processServerMessages(channel: ref CadetChannel)
{.async.} =
return
echo getDateStr()," ",getClockStr()," ",message
-proc processInput(inputFile: AsyncFile, channel: ref CadetChannel) {.async.} =
+proc processInput(inputFile: AsyncFile, channel: ref CadetChannel, nb: NimBox)
{.async.} =
+ var line = ""
while true:
- let input = await inputFile.readline()
- channel.sendMessage(input)
+ let ch = await inputFile.read(1)
+ case ch
+ of "\n":
+ line = ""
+ else:
+ line.add(ch)
+ nb.print(0, 11, line)
+ nb.present()
proc firstTask(gnunetApp: ref GnunetApplication,
server: string,
@@ -42,8 +49,10 @@ proc firstTask(gnunetApp: ref GnunetApplication,
if not server.isNil():
let inputFile = openAsync("/dev/stdin", fmRead)
let channel = cadet.createChannel(server, port)
- await processServerMessages(channel) or processInput(inputFile, channel)
+ let nb = newNimbox()
+ await processServerMessages(channel) or processInput(inputFile, channel,
nb)
inputFile.close()
+ nb.shutdown()
else:
let cadetPort = cadet.openPort(port)
while true:
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet-nim] 52/61: workaround for missing notification about disconnected cadet channels, (continued)
- [GNUnet-SVN] [gnunet-nim] 52/61: workaround for missing notification about disconnected cadet channels, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 09/61: fix compilation, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 60/61: Start of a nimble file, should probably drop nake later on., gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 49/61: added date and time string to output, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 10/61: fix compilation (2), gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 23/61: receiving of cadet messages possible now, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 51/61: Merge branch 'master' of ssh://gnunet.org/gnunet-nim, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 50/61: load config file in release mode too (fixes segfault), gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 36/61: use immutable variables where possible, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 33/61: add support for input and output file, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 54/61: try out nimbox,
gnunet <=
- [GNUnet-SVN] [gnunet-nim] 55/61: Revert "try out nimbox", gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 57/61: Add nakefile, nim.cfg, and ignore more things, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 47/61: examples/{start, stop}_peers: Use /bin/sh, tested and checked against Bash and shellcheck., gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 61/61: nimble, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 42/61: add first version of groupchat application, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 41/61: move example applications / scripts / config files to example folder, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 59/61: gitignore, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 58/61: groupchat: improve CLI UX, gnunet, 2019/04/13