Высокопроизводительная индексация клиентов внутри протокола
This commit is contained in:
44
src/main/java/com/rosetta/im/client/ClientManager.java
Normal file
44
src/main/java/com/rosetta/im/client/ClientManager.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.rosetta.im.client;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.rosetta.im.client.tags.ECIAuthentificate;
|
||||
|
||||
import io.orprotocol.Server;
|
||||
import io.orprotocol.client.Client;
|
||||
import io.orprotocol.index.ClientIndexer;
|
||||
|
||||
/**
|
||||
* Менеджер клиентов
|
||||
*/
|
||||
public class ClientManager {
|
||||
|
||||
private Server server;
|
||||
private ClientIndexer clientIndexer;
|
||||
|
||||
public ClientManager(Server server) {
|
||||
this.server = server;
|
||||
this.clientIndexer = server.getClientIndexer();
|
||||
}
|
||||
|
||||
public Server getServer() {
|
||||
return this.server;
|
||||
}
|
||||
|
||||
public boolean isClientConnected(String publicKey) {
|
||||
HashSet<Client> clients = this.clientIndexer.getClients(ECIAuthentificate.class, "publicKey", publicKey);
|
||||
if(clients.size() > 0){
|
||||
/**
|
||||
* Есть клиенты с таким публичным ключом
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Нет клиентов с таким ключом
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user