diff --git a/core/src/main/groovy/com/muwire/core/connection/Connection.groovy b/core/src/main/groovy/com/muwire/core/connection/Connection.groovy new file mode 100644 index 00000000..b6002d0e --- /dev/null +++ b/core/src/main/groovy/com/muwire/core/connection/Connection.groovy @@ -0,0 +1,30 @@ +package com.muwire.core.connection + +import com.muwire.core.EventBus + +import net.i2p.data.Destination + +abstract class Connection { + + final EventBus eventBus + final InputStream inputStream + final OutputStream outputStream + final Destination remoteSide + final boolean incoming + + Connection(EventBus eventBus, InputStream inputStream, OutputStream outputStream, + Destination remoteSide, boolean incoming) { + this.eventBus = eventBus + this.inputStream = inputStream + this.outputStream = outputStream + this.remoteSide = remoteSide + this.incoming = incoming + } + + /** + * starts the connection threads + */ + void start() { + + } +} diff --git a/core/src/main/groovy/com/muwire/core/connection/LeafConnection.groovy b/core/src/main/groovy/com/muwire/core/connection/LeafConnection.groovy new file mode 100644 index 00000000..7c1cf8b7 --- /dev/null +++ b/core/src/main/groovy/com/muwire/core/connection/LeafConnection.groovy @@ -0,0 +1,21 @@ +package com.muwire.core.connection + +import java.io.InputStream +import java.io.OutputStream + +import com.muwire.core.EventBus + +import net.i2p.data.Destination + +/** + * Connection where the other side is a leaf. + * Such connections can only be incoming. + * @author zab + */ +class LeafConnection extends Connection { + + public LeafConnection(EventBus eventBus, InputStream inputStream, OutputStream outputStream, Destination remoteSide) { + super(eventBus, inputStream, outputStream, remoteSide, true); + } + +} diff --git a/core/src/main/groovy/com/muwire/core/connection/PeerConnection.groovy b/core/src/main/groovy/com/muwire/core/connection/PeerConnection.groovy new file mode 100644 index 00000000..42a79bbd --- /dev/null +++ b/core/src/main/groovy/com/muwire/core/connection/PeerConnection.groovy @@ -0,0 +1,21 @@ +package com.muwire.core.connection + +import java.io.InputStream +import java.io.OutputStream + +import com.muwire.core.EventBus + +import net.i2p.data.Destination + +/** + * This side is an ultrapeer and the remote is an ultrapeer too + * @author zab + */ +class PeerConnection extends Connection { + + public PeerConnection(EventBus eventBus, InputStream inputStream, OutputStream outputStream, Destination remoteSide, + boolean incoming) { + super(eventBus, inputStream, outputStream, remoteSide, incoming) + } + +} diff --git a/core/src/main/groovy/com/muwire/core/connection/UltrapeerConnection.groovy b/core/src/main/groovy/com/muwire/core/connection/UltrapeerConnection.groovy new file mode 100644 index 00000000..05c76bed --- /dev/null +++ b/core/src/main/groovy/com/muwire/core/connection/UltrapeerConnection.groovy @@ -0,0 +1,23 @@ +package com.muwire.core.connection + +import java.io.InputStream +import java.io.OutputStream + +import com.muwire.core.EventBus + +import net.i2p.data.Destination + +/** + * Connection where this side is a leaf and the + * other side an ultrapeer. Such connections can only + * be outgoing + * @author zab + */ +class UltrapeerConnection extends Connection { + + public UltrapeerConnection(EventBus eventBus, InputStream inputStream, OutputStream outputStream, + Destination remoteSide) { + super(eventBus, inputStream, outputStream, remoteSide, false) + } + +}