From a004bd430a88a719af445e89df164060f87e62da Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Fri, 27 Jul 2018 14:51:31 +0100 Subject: [PATCH] start connection manager, fix some issues --- core/src/main/groovy/com/muwire/core/Core.groovy | 1 + .../groovy/com/muwire/core/connection/ConnectionManager.groovy | 2 +- .../groovy/com/muwire/core/connection/PeerConnection.groovy | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/groovy/com/muwire/core/Core.groovy b/core/src/main/groovy/com/muwire/core/Core.groovy index f5d81e27..3658067b 100644 --- a/core/src/main/groovy/com/muwire/core/Core.groovy +++ b/core/src/main/groovy/com/muwire/core/Core.groovy @@ -88,6 +88,7 @@ class Core { new LeafConnectionManager(eventBus,3, hostCache) : new UltrapeerConnectionManager(eventBus, 512, 512, hostCache) eventBus.register(TrustEvent.class, connectionManager) eventBus.register(ConnectionEvent.class, connectionManager) + connectionManager.start() log.info("initializing cache client") CacheClient cacheClient = new CacheClient(eventBus,hostCache, connectionManager, i2pSession, props, 10000) diff --git a/core/src/main/groovy/com/muwire/core/connection/ConnectionManager.groovy b/core/src/main/groovy/com/muwire/core/connection/ConnectionManager.groovy index c5abe973..1c031085 100644 --- a/core/src/main/groovy/com/muwire/core/connection/ConnectionManager.groovy +++ b/core/src/main/groovy/com/muwire/core/connection/ConnectionManager.groovy @@ -53,7 +53,7 @@ abstract class ConnectionManager { abstract void onConnectionEvent(ConnectionEvent e) - private void sendPings() { + protected void sendPings() { final long now = System.currentTimeMillis() getConnections().each { if (now - it.lastPingSentTime > PING_TIME) diff --git a/core/src/main/groovy/com/muwire/core/connection/PeerConnection.groovy b/core/src/main/groovy/com/muwire/core/connection/PeerConnection.groovy index 39094c88..2dc1a078 100644 --- a/core/src/main/groovy/com/muwire/core/connection/PeerConnection.groovy +++ b/core/src/main/groovy/com/muwire/core/connection/PeerConnection.groovy @@ -63,7 +63,7 @@ class PeerConnection extends Connection { byte [] payload if (message instanceof Map) { payload = JsonOutput.toJson(message) - DataUtil.packHeader(payload.bytes.length, writeHeader) + DataUtil.packHeader(payload.length, writeHeader) writeHeader[0] &= 0x7F } else { // TODO: write binary