Fix main, Add debug output

This commit is contained in:
MrLetsplay 2023-12-11 13:27:27 +01:00
parent 46738ab51a
commit ca5f0567e1
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
2 changed files with 2 additions and 6 deletions

View File

@ -8,7 +8,7 @@ public class ShareServer {
private static final Map<String, Session> SESSIONS = new HashMap<>(); private static final Map<String, Session> SESSIONS = new HashMap<>();
public static void main(String[] args) { public static void main(String[] args) {
new ShareWSServer().start(); new ShareWSServer().run();
} }
public static Session getOrCreateSession(String sessionID) { public static Session getOrCreateSession(String sessionID) {

View File

@ -85,6 +85,7 @@ public class ShareWSServer extends WebSocketServer {
SessionUser user = conn.getAttachment(); SessionUser user = conn.getAttachment();
Session session = user.session(); Session session = user.session();
boolean isHost = getHost(getPeers(session)).equals(conn); boolean isHost = getHost(getPeers(session)).equals(conn);
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).forEach(peer -> send(peer, m));
case REQUEST_FULL_SYNC, REQUEST_CHECKSUM -> { case REQUEST_FULL_SYNC, REQUEST_CHECKSUM -> {
@ -114,11 +115,6 @@ public class ShareWSServer extends WebSocketServer {
conn.close(CloseFrame.POLICY_VALIDATION, "Invalid message received"); conn.close(CloseFrame.POLICY_VALIDATION, "Invalid message received");
} }
} }
// System.out.println("Got a message");
// getConnections().forEach(c -> {
// if(conn != c) c.send(message);
// });
} }
private List<WebSocket> getPeers(Session session) { private List<WebSocket> getPeers(Session session) {