From dcd2c03d4553820d69e553e9482abd6b7327533f Mon Sep 17 00:00:00 2001 From: Christian Ulrich Date: Sun, 16 Aug 2020 12:41:07 +0200 Subject: [PATCH] introduce AcceptPort constant; add debug output --- examples/app/app.nim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/app/app.nim b/examples/app/app.nim index 114c239..2a12c45 100644 --- a/examples/app/app.nim +++ b/examples/app/app.nim @@ -5,6 +5,8 @@ import asyncutils import ../../message import random +const AcceptPort = Port(2000) + type PunchdResponse = Future[tuple[msgContent: string, sock: AsyncSocket]] PunchdProgressCb = proc (future: PunchdResponse, msgContent: string) {.async.} @@ -186,6 +188,7 @@ proc initServerConnection(serverHostname: string, serverPort: Port, assert(args[0] == "ok") assert(args[1] == $id) let endpoint = parseMessage[OkGetEndpoint](args[2]) + echo "endpoint: ", endpoint result.probedIp = endpoint.ip result.probedPorts.add(endpoint.port) let emptyLine = await sock.recvLine(maxLength = 400) @@ -208,10 +211,10 @@ proc runApp(serverHostname: string, serverPort: Port, peerId: string, if otherPeerId.len == 0: # register and wait for connections let serverConn = await initServerConnection(serverHostname, serverPort, - Port(4321)) + AcceptPort) asyncCheck handleServerMessages(serverConn) asyncCheck handlePeerNotifications(serverConn, punchdConn, peerId) - let myPorts = (@[Port(4321)] & serverConn.probedPorts).join(",") + let myPorts = (@[AcceptPort] & serverConn.probedPorts).join(",") let req = &"{peerId}|{serverConn.probedIp}|{myPorts}" echo "registering: ", req discard await serverConn.sendRequest("register", req)