32 lines
1.0 KiB
Java
32 lines
1.0 KiB
Java
package envoy.server.processors;
|
|
|
|
import java.io.IOException;
|
|
|
|
import envoy.event.NameChange;
|
|
import envoy.server.data.Contact;
|
|
import envoy.server.data.PersistenceManager;
|
|
import envoy.server.net.ObjectWriteProxy;
|
|
|
|
/**
|
|
* Project: <strong>envoy-server-standalone</strong><br>
|
|
* File: <strong>NameChangeProcessor.java</strong><br>
|
|
* Created: <strong>26 Mar 2020</strong><br>
|
|
*
|
|
* @author Leon Hofmeister
|
|
* @since Envoy Server Standalone v0.1-beta
|
|
*/
|
|
public class NameChangeProcessor implements ObjectProcessor<NameChange> {
|
|
|
|
private static final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
|
|
|
@Override
|
|
public void process(NameChange nameChange, long socketID, ObjectWriteProxy writeProxy) throws IOException {
|
|
Contact toUpdate = persistenceManager.getContactByID(nameChange.getID());
|
|
toUpdate.setName(nameChange.get());
|
|
persistenceManager.updateContact(toUpdate);
|
|
|
|
// Notify online contacts of the name change
|
|
writeProxy.writeToOnlineContacts(toUpdate.getContacts(), nameChange);
|
|
}
|
|
}
|