[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet-nim] 25/61: fix sending messages
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet-nim] 25/61: fix sending messages |
Date: |
Sat, 13 Apr 2019 13:36:00 +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 ccb6b303e6710fc1ee85a4e88da97526fa648993
Author: lurchi <address@hidden>
AuthorDate: Sat Aug 4 17:26:59 2018 +0200
fix sending messages
---
asynccadet.nim | 5 +++--
gnunet_nim.nim | 3 +--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/asynccadet.nim b/asynccadet.nim
index 5c9f9da..aaf11d0 100644
--- a/asynccadet.nim
+++ b/asynccadet.nim
@@ -75,8 +75,7 @@ proc messageHandlers(): array[2, GNUNET_MQ_MessageHandler] =
]
proc hashString(port: string): GNUNET_HashCode =
- var port: cstring = port
- GNUNET_CRYPTO_hash(port, csize(port.len()), addr result)
+ GNUNET_CRYPTO_hash(cstring(port), csize(port.len()), addr result)
proc sendMessage*(channel: CadetChannel, payload: string) =
let messageLen = uint16(payload.len() + sizeof(GNUNET_MessageHeader))
@@ -84,6 +83,8 @@ proc sendMessage*(channel: CadetChannel, payload: string) =
var envelope = GNUNET_MQ_msg(addr messageHeader,
messageLen,
GNUNET_MESSAGE_TYPE_CADET_CLI)
+ messageHeader = cast[ptr
GNUNET_MessageHeader](cast[ByteAddress](messageHeader) +
sizeof(GNUNET_MessageHeader))
+ copyMem(messageHeader, cstring(payload), payload.len())
GNUNET_MQ_send(GNUNET_CADET_get_mq(channel.handle), envelope)
proc openPort*(handle: var CadetHandle, port: string): ref CadetPort =
diff --git a/gnunet_nim.nim b/gnunet_nim.nim
index d22c35e..32aea5f 100644
--- a/gnunet_nim.nim
+++ b/gnunet_nim.nim
@@ -23,12 +23,12 @@ proc cadetConnect(gnunetApp: ref GnunetApplication,
port: string) {.async.} =
var cadet = await gnunetApp.connectCadet()
let cadetChannel = cadet.createChannel(peer, port)
- cadetChannel.sendMessage("hello!")
while true:
let (hasData, message) = await cadetChannel.messages.read()
if not hasData:
break;
echo "got message: ", message
+ cadetChannel.sendMessage("test")
proc main() =
var peer, port: string
@@ -43,7 +43,6 @@ proc main() =
of cmdEnd:
assert(false)
var gnunetApp = initGnunetApplication("gnunet.conf")
- echo "peer = ", peer, ", port = ", port
if peer.isNil() and not port.isNil():
asyncCheck cadetListen(gnunetApp, port)
elif not peer.isNil() and not port.isNil():
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet-nim] 35/61: use nicer new syntax, (continued)
- [GNUnet-SVN] [gnunet-nim] 35/61: use nicer new syntax, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 31/61: use ref object where we only use heap allocation, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 29/61: fix crashes, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 38/61: comment: explain why we're reading from stdin in a nasty way, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 28/61: newline behaviour like in gnunet-cadet, gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 32/61: Revert "use ref object where we only use heap allocation", gnunet, 2019/04/13
- [GNUnet-SVN] [gnunet-nim] 26/61: first try sending messages from stdin, gnunet, 2019/04/13
- [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 <=
- [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, 2019/04/13
- [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