Merge remote-tracking branch 'origin/subprojects' into subprojects
This commit is contained in:
commit
2fc3a00264
4 changed files with 8 additions and 14 deletions
|
@ -10,8 +10,7 @@ import java.io.Serializable;
|
|||
public class DirectPeerConnection extends PeerConnection {
|
||||
private final TcpConnection connection;
|
||||
|
||||
public DirectPeerConnection(TcpConnection connection, PeerUser user) {
|
||||
super(user);
|
||||
public DirectPeerConnection(TcpConnection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,12 +8,6 @@ import org.jetbrains.annotations.Nullable;
|
|||
import java.io.Serializable;
|
||||
|
||||
public abstract class PeerConnection {
|
||||
protected final PeerUser user;
|
||||
|
||||
protected PeerConnection(PeerUser user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
protected abstract void send(Serializable message, @Nullable SimpleCallback calback, @Nullable ErrorCallback errorCallback);
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,12 +49,12 @@ public class PeerUser extends User implements Comparable<PeerUser> {
|
|||
}
|
||||
|
||||
public void init(TcpConnection tcpConnection, String id, String username, ErrorCallback errorCallback) {
|
||||
connection = new DirectPeerConnection(tcpConnection, this);
|
||||
connection = new DirectPeerConnection(tcpConnection);
|
||||
init(id, username, errorCallback);
|
||||
}
|
||||
|
||||
public void init(Proxy proxy, String id, String username, ErrorCallback errorCallback) {
|
||||
connection = new ProxyPeerConnection(proxy, this);
|
||||
connection = new ProxyPeerConnection(proxy, getId());
|
||||
init(id, username, errorCallback);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,11 @@ import java.io.Serializable;
|
|||
|
||||
public class ProxyPeerConnection extends PeerConnection {
|
||||
private final Proxy proxy;
|
||||
private final String userId;
|
||||
|
||||
public ProxyPeerConnection(Proxy proxy, PeerUser user) {
|
||||
super(user);
|
||||
public ProxyPeerConnection(Proxy proxy, String userId) {
|
||||
this.proxy = proxy;
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,11 +25,11 @@ public class ProxyPeerConnection extends PeerConnection {
|
|||
|
||||
@Override
|
||||
protected void receive(TcpConnection.MessageReceivedCallback callback, ErrorCallback errorCallback) {
|
||||
proxy.receive(user.getId(), callback, errorCallback);
|
||||
proxy.receive(userId, callback, errorCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect() {
|
||||
proxy.disconnectUser(user.getId());
|
||||
proxy.disconnectUser(userId);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue