Search in sources :

Example 1 with ClientRegistry

use of de.janrufmonitor.service.server.ClientRegistry in project janrufmonitor by tbrandt77.

the class ConsoleServerStatus method execute.

public void execute() {
    System.out.println("Server Status:");
    System.out.println("--------------");
    System.out.println();
    IService server = getRuntime().getServiceFactory().getService("Server");
    if (server != null && server.isRunning()) {
        System.out.println("Server started on Port " + getRuntime().getConfigManagerFactory().getConfigManager().getProperty("service.Server", "port"));
        System.out.println();
    }
    ClientRegistry cr = ClientRegistry.getInstance();
    System.out.println("Connected clients: " + cr.getClientCount());
    System.out.println();
    if (cr.getClientCount() > 0) {
        System.out.println("Client details:");
        System.out.println("---------------");
        System.out.println();
        List clients = cr.getAllClients();
        Client c = null;
        for (int i = 0; i < clients.size(); i++) {
            c = (Client) clients.get(i);
            System.out.println("Client: " + c.getClientName() + " (" + c.getClientIP() + ")");
            System.out.println("Port: " + c.getClientPort());
            System.out.println("Send [bytes]: " + c.getByteSend());
            System.out.println("Received [bytes]: " + c.getByteReceived());
            System.out.println("---");
        }
    }
}
Also used : ClientRegistry(de.janrufmonitor.service.server.ClientRegistry) List(java.util.List) Client(de.janrufmonitor.service.server.Client) IService(de.janrufmonitor.service.IService)

Aggregations

IService (de.janrufmonitor.service.IService)1 Client (de.janrufmonitor.service.server.Client)1 ClientRegistry (de.janrufmonitor.service.server.ClientRegistry)1 List (java.util.List)1