diff --git a/core/src/main/groovy/com/muwire/core/Core.groovy b/core/src/main/groovy/com/muwire/core/Core.groovy index 8b59f226..250acf64 100644 --- a/core/src/main/groovy/com/muwire/core/Core.groovy +++ b/core/src/main/groovy/com/muwire/core/Core.groovy @@ -48,6 +48,7 @@ import net.i2p.client.I2PSession import net.i2p.client.streaming.I2PSocketManager import net.i2p.client.streaming.I2PSocketManagerFactory import net.i2p.client.streaming.I2PSocketOptions +import net.i2p.client.streaming.I2PSocketManager.DisconnectListener import net.i2p.crypto.DSAEngine import net.i2p.crypto.SigType import net.i2p.data.Destination @@ -124,6 +125,7 @@ public class Core { } socketManager.getDefaultOptions().setReadTimeout(60000) socketManager.getDefaultOptions().setConnectTimeout(30000) + socketManager.addDisconnectListener({eventBus.publish(new RouterDisconnectedEvent())} as DisconnectListener) i2pSession = socketManager.getSession() def destination = new Destination() diff --git a/core/src/main/groovy/com/muwire/core/RouterDisconnectedEvent.groovy b/core/src/main/groovy/com/muwire/core/RouterDisconnectedEvent.groovy new file mode 100644 index 00000000..fcbb9e5b --- /dev/null +++ b/core/src/main/groovy/com/muwire/core/RouterDisconnectedEvent.groovy @@ -0,0 +1,4 @@ +package com.muwire.core + +class RouterDisconnectedEvent extends Event { +} diff --git a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy index 1640819f..983b6751 100644 --- a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy @@ -11,6 +11,7 @@ import com.muwire.core.Core import com.muwire.core.InfoHash import com.muwire.core.MuWireSettings import com.muwire.core.Persona +import com.muwire.core.RouterDisconnectedEvent import com.muwire.core.connection.ConnectionAttemptStatus import com.muwire.core.connection.ConnectionEvent import com.muwire.core.connection.DisconnectionEvent @@ -135,6 +136,7 @@ class MainFrameModel { core.eventBus.register(UpdateAvailableEvent.class, this) core.eventBus.register(FileDownloadedEvent.class, this) core.eventBus.register(FileUnsharedEvent.class, this) + core.eventBus.register(RouterDisconnectedEvent.class, this) timer.schedule({ if (core.shutdown.get()) @@ -339,6 +341,14 @@ class MainFrameModel { } } + void onRouterDisconnectedEvent(RouterDisconnectedEvent e) { + runInsideUIAsync { + JOptionPane.showMessageDialog(null, "MuWire lost connection to the I2P router and will now exit.", + "Connection to I2P router lost", JOptionPane.WARNING_MESSAGE) + System.exit(0) + } + } + void onFileDownloadedEvent(FileDownloadedEvent e) { if (!core.muOptions.shareDownloadedFiles) return