diff --git a/core/src/main/groovy/com/muwire/core/Core.groovy b/core/src/main/groovy/com/muwire/core/Core.groovy index c5a0d239..996c1b62 100644 --- a/core/src/main/groovy/com/muwire/core/Core.groovy +++ b/core/src/main/groovy/com/muwire/core/Core.groovy @@ -30,6 +30,7 @@ import com.muwire.core.search.SearchEvent import com.muwire.core.search.SearchManager import com.muwire.core.trust.TrustEvent import com.muwire.core.trust.TrustService +import com.muwire.core.upload.UploadManager import com.muwire.core.util.MuWireLogManager import groovy.util.logging.Log @@ -134,6 +135,18 @@ class Core { trustService.start() trustService.waitForLoad() + log.info "initializing file manager" + FileManager fileManager = new FileManager(eventBus) + eventBus.register(FileHashedEvent.class, fileManager) + eventBus.register(FileLoadedEvent.class, fileManager) + eventBus.register(FileDownloadedEvent.class, fileManager) + eventBus.register(FileUnsharedEvent.class, fileManager) + eventBus.register(SearchEvent.class, fileManager) + + log.info "initializing persistence service" + PersisterService persisterService = new PersisterService(new File(home, "files.json"), eventBus, 5000, fileManager) + persisterService.start() + log.info("initializing host cache") File hostStorage = new File(home, "hosts.json") HostCache hostCache = new HostCache(trustService,hostStorage, 30000, props, i2pSession.getMyDestination()) @@ -166,9 +179,14 @@ class Core { eventBus.register(QueryEvent.class, searchManager) eventBus.register(ResultsEvent.class, searchManager) + log.info("initializing upload manager") + UploadManager uploadManager = new UploadManager(eventBus, fileManager) + + log.info("initializing acceptor") I2PAcceptor i2pAcceptor = new I2PAcceptor(socketManager) - ConnectionAcceptor acceptor = new ConnectionAcceptor(eventBus, connectionManager, props, i2pAcceptor, hostCache, trustService, searchManager) + ConnectionAcceptor acceptor = new ConnectionAcceptor(eventBus, connectionManager, props, + i2pAcceptor, hostCache, trustService, searchManager, uploadManager) acceptor.start() @@ -180,17 +198,6 @@ class Core { eventBus.register(FileSharedEvent.class, hasherService) hasherService.start() - log.info "initializing file manager" - FileManager fileManager = new FileManager(eventBus) - eventBus.register(FileHashedEvent.class, fileManager) - eventBus.register(FileLoadedEvent.class, fileManager) - eventBus.register(FileDownloadedEvent.class, fileManager) - eventBus.register(FileUnsharedEvent.class, fileManager) - eventBus.register(SearchEvent.class, fileManager) - - log.info "initializing persistence service" - PersisterService persisterService = new PersisterService(new File(home, "files.json"), eventBus, 5000, fileManager) - persisterService.start() // ... at the end, sleep or execute script diff --git a/core/src/main/groovy/com/muwire/core/connection/ConnectionAcceptor.groovy b/core/src/main/groovy/com/muwire/core/connection/ConnectionAcceptor.groovy index 0af8c80f..6b44e2da 100644 --- a/core/src/main/groovy/com/muwire/core/connection/ConnectionAcceptor.groovy +++ b/core/src/main/groovy/com/muwire/core/connection/ConnectionAcceptor.groovy @@ -13,6 +13,7 @@ import com.muwire.core.Persona import com.muwire.core.hostcache.HostCache import com.muwire.core.trust.TrustLevel import com.muwire.core.trust.TrustService +import com.muwire.core.upload.UploadManager import com.muwire.core.search.InvalidSearchResultException import com.muwire.core.search.ResultsParser import com.muwire.core.search.SearchManager @@ -32,13 +33,14 @@ class ConnectionAcceptor { final HostCache hostCache final TrustService trustService final SearchManager searchManager + final UploadManager uploadManager final ExecutorService acceptorThread final ExecutorService handshakerThreads ConnectionAcceptor(EventBus eventBus, UltrapeerConnectionManager manager, MuWireSettings settings, I2PAcceptor acceptor, HostCache hostCache, - TrustService trustService, searchManager) { + TrustService trustService, SearchManager searchManager, UploadManager uploadManager) { this.eventBus = eventBus this.manager = manager this.settings = settings @@ -46,6 +48,7 @@ class ConnectionAcceptor { this.hostCache = hostCache this.trustService = trustService this.searchManager = searchManager + this.uploadManager = uploadManager acceptorThread = Executors.newSingleThreadExecutor { r -> def rv = new Thread(r) @@ -170,7 +173,7 @@ class ConnectionAcceptor { dis.readFully(et) if (et != "ET ".getBytes(StandardCharsets.US_ASCII)) throw new IOException("Invalid GET connection") - // TODO: implement + uploadManager.processEndpoint(e) } private void processPOST(final Endpoint e) throws IOException {