type hierarchy of connections

This commit is contained in:
Zlatin Balevsky
2018-07-21 21:49:02 +01:00
parent d5de29e62a
commit fd061f615a
4 changed files with 95 additions and 0 deletions

View File

@@ -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() {
}
}

View File

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

View File

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

View File

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