diff --git a/core/src/main/groovy/com/muwire/core/Core.groovy b/core/src/main/groovy/com/muwire/core/Core.groovy index aded4a61..e60a26cd 100644 --- a/core/src/main/groovy/com/muwire/core/Core.groovy +++ b/core/src/main/groovy/com/muwire/core/Core.groovy @@ -194,7 +194,7 @@ public class Core { // options like tunnel length and quantity I2PSocketManager socketManager keyDat.withInputStream { - socketManager = new I2PSocketManagerFactory().createManager(it, i2pOptions["i2cp.tcp.host"], i2pOptions["i2cp.tcp.port"].toInteger(), i2pOptions) + socketManager = new I2PSocketManagerFactory().createDisconnectedManager(it, i2pOptions["i2cp.tcp.host"], i2pOptions["i2cp.tcp.port"].toInteger(), i2pOptions) } socketManager.getDefaultOptions().setReadTimeout(60000) socketManager.getDefaultOptions().setConnectTimeout(30000) @@ -380,6 +380,7 @@ public class Core { } public void startServices() { + i2pSession.connect() hasherService.start() trustService.start() trustService.waitForLoad() diff --git a/gui/griffon-app/lifecycle/Ready.groovy b/gui/griffon-app/lifecycle/Ready.groovy index 0d4caa82..311cdbfb 100644 --- a/gui/griffon-app/lifecycle/Ready.groovy +++ b/gui/griffon-app/lifecycle/Ready.groovy @@ -82,23 +82,23 @@ class Ready extends AbstractLifecycleHandler { Core core try { core = new Core(props, home, metadata["application.version"]) + Runtime.getRuntime().addShutdownHook({ + core.shutdown() + }) + core.startServices() + application.context.put("muwire-settings", props) + application.context.put("core",core) + application.getPropertyChangeListeners("core").each { + it.propertyChange(new PropertyChangeEvent(this, "core", null, core)) + } + + core.eventBus.publish(new UILoadedEvent()) } catch (Exception bad) { log.log(Level.SEVERE,"couldn't initialize core",bad) JOptionPane.showMessageDialog(null, "Couldn't connect to I2P router. Make sure I2P is running and restart MuWire", - "Can't connect to I2P router", JOptionPane.WARNING_MESSAGE) + "Can't connect to I2P router", JOptionPane.WARNING_MESSAGE) System.exit(0) } - Runtime.getRuntime().addShutdownHook({ - core.shutdown() - }) - core.startServices() - application.context.put("muwire-settings", props) - application.context.put("core",core) - application.getPropertyChangeListeners("core").each { - it.propertyChange(new PropertyChangeEvent(this, "core", null, core)) - } - - core.eventBus.publish(new UILoadedEvent()) } private String selectNickname() { diff --git a/webui/src/main/java/com/muwire/webui/MWStarter.java b/webui/src/main/java/com/muwire/webui/MWStarter.java index 15cd849d..b37a4269 100644 --- a/webui/src/main/java/com/muwire/webui/MWStarter.java +++ b/webui/src/main/java/com/muwire/webui/MWStarter.java @@ -4,6 +4,7 @@ import java.io.File; import com.muwire.core.Core; import com.muwire.core.MuWireSettings; +import com.muwire.core.UILoadedEvent; class MWStarter extends Thread { private final MuWireSettings settings; @@ -22,7 +23,8 @@ class MWStarter extends Thread { public void run() { Core core = new Core(settings, home, version); - core.startServices(); client.setCore(core); + core.startServices(); + core.getEventBus().publish(new UILoadedEvent()); } } diff --git a/webui/src/main/java/com/muwire/webui/MuWireClient.java b/webui/src/main/java/com/muwire/webui/MuWireClient.java index 52f9c082..56fcee89 100644 --- a/webui/src/main/java/com/muwire/webui/MuWireClient.java +++ b/webui/src/main/java/com/muwire/webui/MuWireClient.java @@ -171,8 +171,6 @@ public class MuWireClient { servletContext.setAttribute("trustManager", trustManager); servletContext.setAttribute("certificateManager", certificateManager); servletContext.setAttribute("uploadManager", uploadManager); - - core.getEventBus().publish(new UILoadedEvent()); } public String getHome() {