type hierarchy of connections
This commit is contained in:
@@ -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() {
|
||||
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
|
||||
}
|
@@ -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)
|
||||
}
|
||||
|
||||
}
|
@@ -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)
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user