Don't forward messags to sender peer
This commit is contained in:
parent
ca5f0567e1
commit
30c81163ce
@ -87,7 +87,11 @@ public class ShareWSServer extends WebSocketServer {
|
|||||||
boolean isHost = getHost(getPeers(session)).equals(conn);
|
boolean isHost = getHost(getPeers(session)).equals(conn);
|
||||||
System.out.println("[" + user.siteID() + "] " + m);
|
System.out.println("[" + user.siteID() + "] " + m);
|
||||||
switch(m.getType()) {
|
switch(m.getType()) {
|
||||||
case CHANGE -> getPeers(session).forEach(peer -> send(peer, m));
|
case CHANGE -> {
|
||||||
|
getPeers(session).stream()
|
||||||
|
.filter(p -> p.<SessionUser>getAttachment().siteID() != user.siteID())
|
||||||
|
.forEach(peer -> send(peer, m));
|
||||||
|
}
|
||||||
case REQUEST_FULL_SYNC, REQUEST_CHECKSUM -> {
|
case REQUEST_FULL_SYNC, REQUEST_CHECKSUM -> {
|
||||||
AddressableMessage msg = (AddressableMessage) m;
|
AddressableMessage msg = (AddressableMessage) m;
|
||||||
if(msg.siteID() != user.siteID()) {
|
if(msg.siteID() != user.siteID()) {
|
||||||
@ -105,7 +109,9 @@ public class ShareWSServer extends WebSocketServer {
|
|||||||
|
|
||||||
AddressableMessage msg = (AddressableMessage) m;
|
AddressableMessage msg = (AddressableMessage) m;
|
||||||
if(msg.siteID() == AddressableMessage.BROADCAST_SITE_ID) {
|
if(msg.siteID() == AddressableMessage.BROADCAST_SITE_ID) {
|
||||||
getPeers(session).forEach(peer -> send(peer, m));
|
getPeers(session).stream()
|
||||||
|
.filter(p -> p.<SessionUser>getAttachment().siteID() != user.siteID())
|
||||||
|
.forEach(peer -> send(peer, m));
|
||||||
}else {
|
}else {
|
||||||
WebSocket peer = getPeer(getPeers(session), msg.siteID());
|
WebSocket peer = getPeer(getPeers(session), msg.siteID());
|
||||||
if(peer != null) send(peer, m);
|
if(peer != null) send(peer, m);
|
||||||
|
Loading…
Reference in New Issue
Block a user