Fixed ConnectionManager#isOnline(long), moved ConnectionManager to net

This commit is contained in:
Kai S. K. Engelbart 2020-02-12 22:01:32 +01:00
parent e84d88aa88
commit 9a06ed4a45
9 changed files with 12 additions and 11 deletions

View File

@ -8,6 +8,7 @@ import com.jenkov.nioserver.Server;
import envoy.server.data.ConfigItem; import envoy.server.data.ConfigItem;
import envoy.server.database.PersistenceManager; import envoy.server.database.PersistenceManager;
import envoy.server.net.ConnectionManager;
import envoy.server.net.ObjectMessageProcessor; import envoy.server.net.ObjectMessageProcessor;
import envoy.server.net.ObjectMessageReader; import envoy.server.net.ObjectMessageReader;
import envoy.server.processors.*; import envoy.server.processors.*;

View File

@ -8,10 +8,10 @@ import javax.persistence.EntityTransaction;
import javax.persistence.Persistence; import javax.persistence.Persistence;
import envoy.data.User.UserStatus; import envoy.data.User.UserStatus;
import envoy.server.ConnectionManager;
import envoy.server.data.ConfigItem; import envoy.server.data.ConfigItem;
import envoy.server.data.Message; import envoy.server.data.Message;
import envoy.server.data.User; import envoy.server.data.User;
import envoy.server.net.ConnectionManager;
/** /**
* Project: <strong>envoy-server-standalone</strong><br> * Project: <strong>envoy-server-standalone</strong><br>

View File

@ -1,4 +1,4 @@
package envoy.server; package envoy.server.net;
import java.util.*; import java.util.*;
@ -46,14 +46,14 @@ public class ConnectionManager implements ISocketIdListener {
@Override @Override
public void socketCancelled(long socketId) { public void socketCancelled(long socketId) {
if (!pendingSockets.remove(socketId)) { if (!pendingSockets.remove(socketId)) {
// notifying contacts of this users offline-going // Notify contacts of this users offline-going
envoy.server.data.User user = PersistenceManager.getInstance().getUserById(getUserIdBySocketId(socketId)); envoy.server.data.User user = PersistenceManager.getInstance().getUserById(getUserIdBySocketId(socketId));
user.setStatus(UserStatus.OFFLINE); user.setStatus(UserStatus.OFFLINE);
user.setLastSeen(new Date()); user.setLastSeen(new Date());
UserStatusChangeProcessor.updateUserStatus(user); UserStatusChangeProcessor.updateUserStatus(user);
// removing the socket // Remove the socket
sockets.entrySet().stream().filter(e -> e.getValue() == socketId).forEach(e -> sockets.remove(e.getValue())); sockets.entrySet().removeIf(e -> e.getValue() == socketId);
} }
} }

View File

@ -5,9 +5,9 @@ import java.util.Arrays;
import envoy.data.Contacts; import envoy.data.Contacts;
import envoy.event.ContactOperationEvent; import envoy.event.ContactOperationEvent;
import envoy.server.ConnectionManager;
import envoy.server.ObjectProcessor; import envoy.server.ObjectProcessor;
import envoy.server.database.PersistenceManager; import envoy.server.database.PersistenceManager;
import envoy.server.net.ConnectionManager;
import envoy.server.net.ObjectWriteProxy; import envoy.server.net.ObjectWriteProxy;
/** /**

View File

@ -6,10 +6,10 @@ import java.util.stream.Collectors;
import envoy.data.Contacts; import envoy.data.Contacts;
import envoy.event.ContactSearchRequest; import envoy.event.ContactSearchRequest;
import envoy.event.ContactSearchResult; import envoy.event.ContactSearchResult;
import envoy.server.ConnectionManager;
import envoy.server.ObjectProcessor; import envoy.server.ObjectProcessor;
import envoy.server.data.User; import envoy.server.data.User;
import envoy.server.database.PersistenceManager; import envoy.server.database.PersistenceManager;
import envoy.server.net.ConnectionManager;
import envoy.server.net.ObjectWriteProxy; import envoy.server.net.ObjectWriteProxy;
/** /**

View File

@ -12,10 +12,10 @@ import envoy.data.Message.MessageStatus;
import envoy.data.User; import envoy.data.User;
import envoy.data.User.UserStatus; import envoy.data.User.UserStatus;
import envoy.event.HandshakeRejectionEvent; import envoy.event.HandshakeRejectionEvent;
import envoy.server.ConnectionManager;
import envoy.server.ObjectProcessor; import envoy.server.ObjectProcessor;
import envoy.server.data.Message; import envoy.server.data.Message;
import envoy.server.database.PersistenceManager; import envoy.server.database.PersistenceManager;
import envoy.server.net.ConnectionManager;
import envoy.server.net.ObjectWriteProxy; import envoy.server.net.ObjectWriteProxy;
/** /**

View File

@ -5,9 +5,9 @@ import java.util.Date;
import envoy.data.Message; import envoy.data.Message;
import envoy.event.MessageStatusChangeEvent; import envoy.event.MessageStatusChangeEvent;
import envoy.server.ConnectionManager;
import envoy.server.ObjectProcessor; import envoy.server.ObjectProcessor;
import envoy.server.database.PersistenceManager; import envoy.server.database.PersistenceManager;
import envoy.server.net.ConnectionManager;
import envoy.server.net.ObjectWriteProxy; import envoy.server.net.ObjectWriteProxy;
/** /**

View File

@ -5,9 +5,9 @@ import java.io.IOException;
import envoy.data.Message.MessageStatus; import envoy.data.Message.MessageStatus;
import envoy.event.MessageStatusChangeEvent; import envoy.event.MessageStatusChangeEvent;
import envoy.exception.EnvoyException; import envoy.exception.EnvoyException;
import envoy.server.ConnectionManager;
import envoy.server.ObjectProcessor; import envoy.server.ObjectProcessor;
import envoy.server.database.PersistenceManager; import envoy.server.database.PersistenceManager;
import envoy.server.net.ConnectionManager;
import envoy.server.net.ObjectWriteProxy; import envoy.server.net.ObjectWriteProxy;
/** /**

View File

@ -4,10 +4,10 @@ import java.io.IOException;
import envoy.data.User.UserStatus; import envoy.data.User.UserStatus;
import envoy.event.UserStatusChangeEvent; import envoy.event.UserStatusChangeEvent;
import envoy.server.ConnectionManager;
import envoy.server.ObjectProcessor; import envoy.server.ObjectProcessor;
import envoy.server.data.User; import envoy.server.data.User;
import envoy.server.database.PersistenceManager; import envoy.server.database.PersistenceManager;
import envoy.server.net.ConnectionManager;
import envoy.server.net.ObjectWriteProxy; import envoy.server.net.ObjectWriteProxy;
/** /**