start connection manager, fix some issues

pull/4/head
Zlatin Balevsky 2018-07-27 14:51:31 +01:00
parent 4e31f216a8
commit a004bd430a
3 changed files with 3 additions and 2 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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