29 lines
830 B
Java
29 lines
830 B
Java
package envoy.server.processors;
|
|
|
|
import java.io.IOException;
|
|
|
|
import envoy.event.NameChange;
|
|
|
|
import envoy.server.data.*;
|
|
import envoy.server.net.ObjectWriteProxy;
|
|
|
|
/**
|
|
* @author Leon Hofmeister
|
|
* @since Envoy Server Standalone v0.1-beta
|
|
*/
|
|
public final 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);
|
|
}
|
|
}
|