Implemented suggestions from code review

This commit is contained in:
DieGurke 2020-06-11 15:06:06 +02:00
parent bbf688dbe9
commit 5ef46d80c3
5 changed files with 8 additions and 24 deletions

View File

@ -18,7 +18,6 @@ import envoy.data.MessageBuilder;
* @author Maximilian Käfer
* @since Envoy Server Standalone v0.1-beta
*/
@Entity
public class GroupMessage extends Message {

View File

@ -2,16 +2,7 @@ package envoy.server.data;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.*;
import envoy.data.MessageBuilder;

View File

@ -1,6 +1,10 @@
package envoy.server.net;
import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import com.jenkov.nioserver.ISocketIdListener;
@ -111,9 +115,6 @@ public class ConnectionManager implements ISocketIdListener {
* @since Envoy Server Standalone v0.1-beta
*/
public Set<Long> getOnlineUsersOfGroup(Group group) {
Set<Long> onlineMembers = new HashSet<>();
Set<Long> members = group.getContacts().stream().map(envoy.server.data.Contact::getID).collect(Collectors.toSet());
members.forEach(userID -> { if (isOnline(userID)) onlineMembers.add(userID); });
return onlineMembers;
return group.getContacts().stream().map(envoy.server.data.Contact::getID).filter(this::isOnline).collect(Collectors.toSet());
}
}

View File

@ -8,7 +8,6 @@ import javax.persistence.EntityExistsException;
import envoy.data.GroupMessage;
import envoy.data.Message.MessageStatus;
import envoy.event.MessageStatusChangeEvent;
import envoy.server.data.PersistenceManager;
import envoy.server.net.ConnectionManager;
import envoy.server.net.ObjectWriteProxy;
@ -30,12 +29,6 @@ public class GroupMessageProcessor implements ObjectProcessor<GroupMessage> {
public void process(GroupMessage groupMessage, long socketID, ObjectWriteProxy writeProxy) {
groupMessage.nextStatus();
ConnectionManager connectionManager = ConnectionManager.getInstance();
try {
writeProxy.write(socketID, new MessageStatusChangeEvent(groupMessage));
} catch (IOException e) {
logger.warning("Could not send messageStatusChangeEvent to the sender of this groupMessage with ID: " + groupMessage.getID());
e.printStackTrace();
}
final var members = PersistenceManager.getInstance().getGroupByID(groupMessage.getRecipientID()).getContacts();
for (long i = 0; i < groupMessage.getMemberStatuses().size(); i++) {

View File

@ -49,7 +49,7 @@ public class GroupResizeProcessor implements ObjectProcessor<GroupResizeEvent> {
.map(connectionManager::getSocketId)
.forEach(memberSocketID -> {
try {
writeProxy.write(memberSocketID, commonGroup);
writeProxy.write(memberSocketID, commonGroup);
} catch (IOException e) {
e.printStackTrace();
}