Implemented a GroupCreationProcessor and revised/added Javadoc

This commit is contained in:
DieGurke 2020-03-26 17:09:52 +01:00
parent 732a2d49e6
commit 5685a3e661
4 changed files with 47 additions and 4 deletions

View File

@ -46,7 +46,7 @@ public class Group extends Contact {
/**
* Sets the members of this group.
*
* @param Members a list of all users, that should be assigned to this group.
* @param members a list of all users, that should be assigned to this group.
* @since Envoy Server Standalone v0.1-beta
*/
public void setMembers(List<User> members) { this.members = members; }

View File

@ -52,7 +52,7 @@ public class PersistenceManager {
/**
* Adds a {@link Contact} to the database.
*
* @param user the {@link Contact} to add to the database
* @param contact the {@link Contact} to add to the database
* @since Envoy Server Standalone v0.1-alpha
*/
public void addContact(Contact contact) { persist(contact); }
@ -76,7 +76,7 @@ public class PersistenceManager {
/**
* Updates a {@link Contact} in the database
*
* @param user the {@link Contact} to add to the database
* @param contact the {@link Contact} to add to the database
* @since Envoy Server Standalone v0.1-alpha
*/
public void updateContact(Contact contact) { merge(contact); }
@ -100,7 +100,7 @@ public class PersistenceManager {
/**
* Deletes a {@link Contact} in the database.
*
* @param user the {@link Contact} to delete
* @param contact the {@link Contact} to delete
* @since Envoy Server Standalone v0.1-alpha
*/
public void deleteContact(Contact contact) { remove(contact); }

View File

@ -0,0 +1,34 @@
package envoy.server.processors;
import java.io.IOException;
import envoy.event.GroupCreationEvent;
import envoy.server.data.PersistenceManager;
import envoy.server.net.ObjectWriteProxy;
/**
* Project: <strong>envoy-server-standalone</strong><br>
* File: <strong>GroupCreationProcessor.java</strong><br>
* Created: <strong>26.03.2020</strong><br>
*
* @author Maximilian K&auml;fer
* @since Envoy Server Standalone v0.1-beta
*/
public class GroupCreationProcessor implements ObjectProcessor<GroupCreationEvent> {
private final PersistenceManager persistenceManager = PersistenceManager.getInstance();
@Override
public void process(GroupCreationEvent input, long socketId, ObjectWriteProxy writeProxy) throws IOException {
envoy.server.data.Group group = new envoy.server.data.Group();
group.setName(input.get());
// TODO adjust event, so it sends a members list as well, which can be initially
// set here
persistenceManager.addContact(group);
writeProxy.write(socketId, group); // TODO Prepare the client to receive the group object after sending the
// groupCreationEvent to the server.
}
@Override
public Class<GroupCreationEvent> getInputClass() { return GroupCreationEvent.class; }
}

View File

@ -33,8 +33,17 @@ public class IDGeneratorRequestProcessor implements ObjectProcessor<IDGeneratorR
writeProxy.write(socketId, generator);
}
/**
* @return a new IDGenerator
* @since Envoy Server Standalone v0.1-beta
*/
public static IDGenerator createIDGenerator() { return createIDGenerator(ID_RANGE); }
/**
* @param range of IDs used by the new IDGenerator
* @return a new IDGenerator with a specific range of IDs
* @since Envoy Server Standalone v0.1-beta
*/
public static IDGenerator createIDGenerator(long range) {
ConfigItem currentId = PersistenceManager.getInstance().getConfigItemById("currentMessageId");
IDGenerator generator = new IDGenerator(Integer.parseInt(currentId.getValue()), range);