Fixed user search
This commit is contained in:
		| @@ -10,7 +10,12 @@ import envoy.server.data.ConfigItem; | ||||
| import envoy.server.database.PersistenceManager; | ||||
| import envoy.server.net.ObjectMessageProcessor; | ||||
| import envoy.server.net.ObjectMessageReader; | ||||
| import envoy.server.processors.*; | ||||
| import envoy.server.processors.ContactsRequestProcesor; | ||||
| import envoy.server.processors.IdGeneratorRequestProcessor; | ||||
| import envoy.server.processors.LoginCredentialProcessor; | ||||
| import envoy.server.processors.MessageProcessor; | ||||
| import envoy.server.processors.MessageStatusChangeProcessor; | ||||
| import envoy.server.processors.UserStatusChangeProcessor; | ||||
|  | ||||
| /** | ||||
|  * Starts the server.<br> | ||||
| @@ -38,6 +43,7 @@ public class Startup { | ||||
| 		processors.add(new MessageStatusChangeProcessor()); | ||||
| 		processors.add(new UserStatusChangeProcessor()); | ||||
| 		processors.add(new IdGeneratorRequestProcessor()); | ||||
| 		processors.add(new ContactsRequestProcesor()); | ||||
| 		Server server = new Server(8080, () -> new ObjectMessageReader(), new ObjectMessageProcessor(processors)); | ||||
|  | ||||
| 		initializeCurrentMessageId(); | ||||
|   | ||||
| @@ -177,7 +177,7 @@ public class PersistenceManager { | ||||
| 	} | ||||
|  | ||||
| 	public List<User> searchUsers(String searchPhrase) { | ||||
| 		return entityManager.createNamedQuery("searchUsers").setParameter("searchPhrase", searchPhrase).getResultList(); | ||||
| 		return entityManager.createNamedQuery("searchUsers").setParameter("searchPhrase", searchPhrase + "%").getResultList(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
|   | ||||
| @@ -3,6 +3,7 @@ package envoy.server.processors; | ||||
| import java.io.IOException; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import envoy.data.Contacts; | ||||
| import envoy.event.ContactsRequest; | ||||
| import envoy.server.ObjectProcessor; | ||||
| import envoy.server.database.PersistenceManager; | ||||
| @@ -21,11 +22,11 @@ public class ContactsRequestProcesor implements ObjectProcessor<ContactsRequest> | ||||
| 	@Override | ||||
| 	public void process(ContactsRequest request, long socketId, ObjectWriteProxy writeProxy) throws IOException { | ||||
| 		writeProxy.write(socketId, | ||||
| 				PersistenceManager.getPersistenceManager() | ||||
| 				new Contacts(PersistenceManager.getPersistenceManager() | ||||
| 					.searchUsers(request.get()) | ||||
| 					.stream() | ||||
| 					.map(envoy.server.data.User::toCommonUser) | ||||
| 					.collect(Collectors.toList())); | ||||
| 					.collect(Collectors.toList()))); | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 DieGurke
					DieGurke