if (input instanceof ServiceObject) {
so = (ServiceObject) input;
if (so.isTag(ServiceTags.KeepAlive)) {
System.out.println("sending keepalive");
ui.getOOS().writeObject(new ServiceObject("Server",ServiceTags.KeepAlive));
//ATMserver.keepAlive(so, ui);
// es wird kontrolliert ob sich der Client angemeldet hat, wenn nicht wird die Verbindung geschlossen
} else if (so.isTag(ServiceTags.ClientLoggedIn)) {
if(model.isNameUnique(so.getSenderName())){
ui.setNickName(so.getSenderName());
model.addUserInfo(ui);
System.out.println(so.getSenderName()+" logged in.");
//Sending functionlist
ServiceObject sout=new ServiceObject("Server",ServiceTags.FunctionList);
sout.setFunctions(model.getFuncs());
System.out.println("Sending functionlist to: "+ui.getNickName());
ui.getOOS().writeObject(sout);
model.getServer().sendUserList(ui);
model.sendUpdateList(ui);
} else {
System.out.println(so.getSenderName()+" already exists, closing connection.");
ui.getOOS().writeObject(new ServiceObject("Server",ServiceTags.NameAlreadyExists));
throw new IOException();
}
}else if (so.isTag(ServiceTags.chatMessage)) {
ServiceObject sout = new ServiceObject(ui.getNickName(), ServiceTags.chatMessage);
sout.setValue(so.getValue());
model.getServer().broadcast(sout, ui);
}
else if (so.isTag(ServiceTags.ClientLoggedOut)) {
throw new IOException();