gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet-nim] branch master updated: try out nimbox


From: gnunet
Subject: [GNUnet-SVN] [gnunet-nim] branch master updated: try out nimbox
Date: Sun, 26 Aug 2018 12:29:45 +0200

This is an automated email from the git hooks/post-receive script.

lurchi pushed a commit to branch master
in repository gnunet-nim.

The following commit(s) were added to refs/heads/master by this push:
     new 9bb3830  try out nimbox
9bb3830 is described below

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]