Merge remote-tracking branch 'origin/subprojects' into subprojects

This commit is contained in:
Arnaud Vergnet 2021-01-31 17:18:24 +01:00
commit 2fc3a00264
4 changed files with 8 additions and 14 deletions

View file

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

View file

@ -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);
/**

View file

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

View file

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