diff --git a/server_connection.nim b/server_connection.nim index c28e72d..cf5318f 100644 --- a/server_connection.nim +++ b/server_connection.nim @@ -62,7 +62,9 @@ proc getEndpoint(srcPort: Port, serverHostname: string, serverPort: Port): proc initServerConnection*(serverHostname: string, serverPort: Port, srcPort: Port, probingServers: seq[Endpoint]): Future[ServerConnection] {.async.} = - result.srcPort = srcPort + result = ServerConnection(outMessages: newTable[string, Future[string]](), + peerNotifications: newFutureStream[string]("initServerConnection"), + srcPort: srcPort) for s in probingServers: let endpoint = await getEndpoint(srcPort, s.hostname, s.port) # FIXME: what if we get get different IPs from different servers @@ -70,8 +72,6 @@ proc initServerConnection*(serverHostname: string, serverPort: Port, result.probedSrcPorts.add(endpoint.port) result.sock = await asyncnet.dial(serverHostname, serverPort) - result.outMessages = newTable[string, Future[string]]() - result.peerNotifications = newFutureStream[string]("initServerConnection") proc handleServerMessages*(conn: ServerConnection) {.async.} = while true: