Updates im Chat-Server
This commit is contained in:
@@ -18,7 +18,6 @@ import java.util.TimerTask;
|
||||
|
||||
import Database.DatabaseHandler;
|
||||
import beyondsoft.bewomitarbeiterapp.BeWoChatApplication;
|
||||
import beyondsoft.bewomitarbeiterapp.R;
|
||||
import entities.ChatEntity;
|
||||
import entities.ChatMessage;
|
||||
import entities.NotificationLog;
|
||||
@@ -26,6 +25,8 @@ import entities.NotificationLog;
|
||||
import soapConnection.DataIdentifier;
|
||||
import soapConnection.Packet;
|
||||
import soapConnection.SoapCalls;
|
||||
import soapConnection.SoapConnectionManager;
|
||||
import util.Util;
|
||||
|
||||
/**
|
||||
* Created by JettenM on 04.08.2016.
|
||||
@@ -188,10 +189,6 @@ public class SocketManager {
|
||||
|
||||
private volatile boolean isRunning = true;
|
||||
|
||||
public void terminate() {
|
||||
isRunning = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
@@ -213,6 +210,7 @@ public class SocketManager {
|
||||
|
||||
try {
|
||||
chatPacket = new Packet(new String(message, "UTF-8"));
|
||||
Log.i("SOCKET_LISTENER", "Erstelle Packet; " + (chatPacket.ChatMessage.isEmpty() ? "<<LEER>>" : chatPacket.ChatMessage) + "; Typ: " + chatPacket.ChatDataIdentifier + ": " + new String(message, "UTF-8"));
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -251,6 +249,30 @@ public class SocketManager {
|
||||
SocketManager.onlinePersonOids.add(chatPacket.SenderPersonOid);
|
||||
}
|
||||
|
||||
//if(!SocketManager.onlineEntities.)
|
||||
|
||||
/*
|
||||
for(Map.Entry<ChatEntity, NotificationLog> entry : SocketManager.notificationEntities.entrySet()) {
|
||||
if(!(entry.getKey().equals(chatEntity) && entry.getValue().equals(notificationLog))) {
|
||||
mNotifyMgr.cancel(entry.getValue().getNotificationId());
|
||||
entities2remove.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
boolean isAlreadyLoggedIn = false;
|
||||
for(ChatEntity entity : SocketManager.onlineEntities)
|
||||
{
|
||||
if(entity.getOid() == chatPacket.SenderPersonOid) {
|
||||
isAlreadyLoggedIn = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isAlreadyLoggedIn) {
|
||||
SocketManager.onlineEntities.add(new ChatEntity(chatPacket.SenderPersonOid, false));
|
||||
}
|
||||
|
||||
break;
|
||||
case STATUS_NOTIFICATION_LOGOUT:
|
||||
|
||||
@@ -258,6 +280,10 @@ public class SocketManager {
|
||||
SocketManager.onlinePersonOids.remove(Integer.valueOf(chatPacket.SenderPersonOid));
|
||||
}
|
||||
|
||||
ChatEntity entity2delete = Util.getChatEntityFromOnlineEntitiesByOid(chatPacket.SenderPersonOid, chatPacket.ChatDataIdentifier == DataIdentifier.TEAM);
|
||||
|
||||
SocketManager.onlineEntities.remove(entity2delete);
|
||||
|
||||
break;
|
||||
|
||||
case STATUS_NOTIFICATION_LOGIN_BROADCAST:
|
||||
@@ -265,7 +291,12 @@ public class SocketManager {
|
||||
String[] onlinePersons = chatPacket.ChatMessage.split(",");
|
||||
|
||||
for (String onlinePerson : onlinePersons) {
|
||||
SocketManager.onlinePersonOids.add(Integer.parseInt(onlinePerson));
|
||||
|
||||
int personOid = Integer.parseInt(onlinePerson);
|
||||
|
||||
if(!SocketManager.onlinePersonOids.contains(personOid)) {
|
||||
SocketManager.onlinePersonOids.add(personOid);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -319,4 +350,4 @@ public class SocketManager {
|
||||
|
||||
return "02:00:00:00:00:00";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user