2020-04-02 16:32:23 +02:00
|
|
|
package envoy.server.processors;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
2020-06-20 09:57:54 +02:00
|
|
|
import envoy.event.NameChange;
|
2020-10-19 18:17:51 +02:00
|
|
|
|
2020-09-25 14:29:23 +02:00
|
|
|
import envoy.server.data.*;
|
2020-04-02 16:32:23 +02:00
|
|
|
import envoy.server.net.ObjectWriteProxy;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Leon Hofmeister
|
|
|
|
* @since Envoy Server Standalone v0.1-beta
|
|
|
|
*/
|
2020-08-22 13:37:07 +02:00
|
|
|
public final class NameChangeProcessor implements ObjectProcessor<NameChange> {
|
2020-04-02 16:32:23 +02:00
|
|
|
|
2020-07-06 11:40:13 +02:00
|
|
|
private static final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
|
|
|
|
2020-04-02 16:32:23 +02:00
|
|
|
@Override
|
2020-10-19 18:17:51 +02:00
|
|
|
public void process(NameChange nameChange, long socketID, ObjectWriteProxy writeProxy)
|
|
|
|
throws IOException {
|
2020-07-06 11:40:13 +02:00
|
|
|
Contact toUpdate = persistenceManager.getContactByID(nameChange.getID());
|
2020-06-20 09:57:54 +02:00
|
|
|
toUpdate.setName(nameChange.get());
|
2020-04-02 16:32:23 +02:00
|
|
|
persistenceManager.updateContact(toUpdate);
|
|
|
|
|
2020-06-20 09:57:54 +02:00
|
|
|
// Notify online contacts of the name change
|
2020-07-06 11:40:13 +02:00
|
|
|
writeProxy.writeToOnlineContacts(toUpdate.getContacts(), nameChange);
|
2020-04-02 16:32:23 +02:00
|
|
|
}
|
|
|
|
}
|