gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet-nim] 05/05: Remove groupchat files, as there is now


From: gnunet
Subject: [GNUnet-SVN] [gnunet-nim] 05/05: Remove groupchat files, as there is now a seperate repo
Date: Mon, 15 Apr 2019 01:31:58 +0200

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

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

commit 6ea779225ebaa95386035852cb483a6c7d5646cb
Author: Devan Carpenter <address@hidden>
AuthorDate: Sun Mar 24 10:45:28 2019 -0700

    Remove groupchat files, as there is now a seperate repo
    
    Groupchat now resides at:
    https://gnunet.org/git/groupchat.git
---
 examples/Makefile      |  5 ---
 examples/groupchat.nim | 97 --------------------------------------------------
 2 files changed, 102 deletions(-)

diff --git a/examples/Makefile b/examples/Makefile
deleted file mode 100644
index e583032..0000000
--- a/examples/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-groupchat: groupchat.nim
-       nim compile $<
-
-run:
-       ./groupchat -p=23014 -c=gnunet1.conf
diff --git a/examples/groupchat.nim b/examples/groupchat.nim
deleted file mode 100644
index b86318e..0000000
--- a/examples/groupchat.nim
+++ /dev/null
@@ -1,97 +0,0 @@
-import ../gnunet_application, ../asynccadet, ../gnunet_utils
-import asyncdispatch, asyncfile, parseopt, strutils, sequtils, times, os
-
-type Chat = object
-  channels: seq[ref CadetChannel]
-
-proc publish(chat: ref Chat, message: string, sender: ref CadetChannel = nil) =
-  let message =
-    if sender.isNil(): message.strip(leading = false)
-    else: "[" & sender.peer.peerId() & "] " & message.strip(leading = false)
-  echo getDatestr(), " ", getClockStr(), " ", message
-  for c in chat.channels:
-    c.sendMessage(message)
-
-proc processClientMessages(channel: ref CadetChannel,
-                           chat: ref Chat) {.async.} =
-  while true:
-    let (hasData, message) = await channel.messages.read()
-    if not hasData:
-      break
-    chat.publish(message = message, sender = channel)
-
-proc processServerMessages(channel: ref CadetChannel) {.async.} =
-  while true:
-    let (hasData, message) = await channel.messages.read()
-    if not hasData:
-      shutdownGnunetApplication()
-      return
-    echo getDateStr()," ",getClockStr()," ",message
-
-proc processInput(inputFile: AsyncFile, channel: ref CadetChannel) {.async.} =
-  while true:
-    let input = await inputFile.readline()
-    channel.sendMessage(input)
-
-proc firstTask(gnunetApp: ref GnunetApplication,
-               server: string,
-               port: string) {.async.} =
-  let cadet = await gnunetApp.initCadet()
-  var chat = new(Chat)
-  chat.channels = newSeq[ref CadetChannel]()
-  if server != "":
-    let inputFile = openAsync("/dev/stdin", fmRead)
-    let channel = cadet.createChannel(server, port)
-    await processServerMessages(channel) or processInput(inputFile, channel)
-    inputFile.close()
-  else:
-    let cadetPort = cadet.openPort(port)
-    while true:
-      let (hasChannel, channel) = await cadetPort.channels.read()
-      if not hasChannel:
-        break
-      let peerId = channel.peer.peerId()
-      chat.publish(message = peerId & " joined\n")
-      let listParticipants =
-        chat.channels.map(proc(c: ref CadetChannel): string = c.peer.peerId)
-      channel.sendMessage("Welcome " & peerId & "! participants: " & 
$listParticipants)
-      chat.channels.add(channel)
-      closureScope:
-        let channel = channel
-        let peerId = peerId
-        proc channelDisconnected(future: Future[void]) =
-          chat.channels.delete(chat.channels.find(channel))
-          chat.publish(message = peerId & " left\n")
-        processClientMessages(channel, chat).addCallback(channelDisconnected)
-
-proc main() =
-  var server, port, configfile: string
-  var optParser = initOptParser()
-  for kind, key, value in optParser.getopt():
-    case kind
-    of cmdLongOption, cmdShortOption:
-      case key
-      of "config", "c": configfile = value
-      of "server", "s": server = value
-      of "port", "p": port = value
-    else:
-      assert(false)
-  if configfile == "":
-    echo "I need a config file to use."
-    echo "  Add -c=<gnunet.conf>"
-    return
-  if port == "":
-    echo "I need a shared secret port to use."
-    echo "  Add -p=<sharedsecret>"
-    return
-  if server == "":
-    echo "Entering server mode."
-  var gnunetApp = initGnunetApplication(configfile)
-  asyncCheck firstTask(gnunetApp, server, port)
-  while hasPendingOperations():
-    poll(gnunetApp.millisecondsUntilTimeout())
-    gnunetApp.doWork()
-  echo "Quitting."
-
-main()
-GC_fullCollect()

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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