[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet-nim] 45/61: use peer IDs as chat identifiers
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet-nim] 45/61: use peer IDs as chat identifiers |
Date: |
Sat, 13 Apr 2019 13:36:20 +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 4eb7568d2b14b1ba64bcc5d2a8056105a7bba03a
Author: lurchi <address@hidden>
AuthorDate: Wed Aug 8 23:52:27 2018 +0200
use peer IDs as chat identifiers
---
examples/groupchat.nim | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/examples/groupchat.nim b/examples/groupchat.nim
index c2786b0..0ee3b9e 100644
--- a/examples/groupchat.nim
+++ b/examples/groupchat.nim
@@ -1,5 +1,5 @@
-import ../gnunet_application, ../asynccadet
-import asyncdispatch, asyncfile, parseopt, strutils
+import ../gnunet_application, ../asynccadet, ../gnunet_utils
+import asyncdispatch, asyncfile, parseopt, strutils, sequtils
type Chat = object
channels: seq[ref CadetChannel]
@@ -7,7 +7,7 @@ type Chat = object
proc publish(chat: ref Chat, message: string, sender: ref CadetChannel = nil) =
let message =
if sender.isNil(): message.strip(leading = false)
- else: "[Alice] " & message.strip(leading = false)
+ else: "[" & sender.peer.peerId() & "] " & message.strip(leading = false)
echo message
for c in chat.channels:
c.sendMessage(message)
@@ -52,14 +52,18 @@ proc firstTask(gnunetApp: ref GnunetApplication,
let (hasChannel, channel) = await cadetPort.channels.read()
if not hasChannel:
break
- chat.publish(message = "X joined\n")
+ 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("Wlcome " & peerId & "! participants: " &
$listParticipants)
chat.channels.add(channel)
- channel.sendMessage("Welcome X! You are talking with: \n")
closureScope:
let channel = channel
+ let peerId = peerId
proc channelDisconnected(future: Future[void]) =
chat.channels.delete(chat.channels.find(channel))
- chat.publish(message = "X left\n")
+ chat.publish(message = peerId & " left\n")
processClientMessages(channel, chat).addCallback(channelDisconnected)
proc main() =
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet-nim] 40/61: fix bug (application hangs when a peer disconnects); fixes & simplifications, (continued)
- [GNUnet-SVN] [gnunet-nim] 40/61: fix bug (application hangs when a peer disconnects); fixes & simplifications, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 34/61: add shutdown logic (allows GNUnet to shutdown on signals), gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 46/61: groupchat.nim: fix typo in echo message, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 25/61: fix sending messages, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 43/61: Merge branch 'master' of ssh://gnunet.org/gnunet-nim, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 21/61: add GNUnet configs and scripts for testing, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 56/61: gnunet_nim.nim: fix import paths to point to parent dir, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 37/61: disconnect from the cadet service when CadetHandle is destroyed, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 53/61: restructure groupchat application, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 44/61: add peer ID string functions, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 45/61: use peer IDs as chat identifiers,
gnunet <=
- [GNUnet-SVN] [gnunet-nim] 48/61: Makefile to clean the build., gnunet, 2019/04/13
- [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