Concurency

22 views
Skip to first unread message

Victor S

unread,
Apr 2, 2016, 2:43:04 PM4/2/16
to quickserver
I have a class that implements ClientCommandHandler and ClientEventHandler where I declared an object.
The problem is that this object remains the same even when I connect from different clients.
My code is:
public class QueryCommandHandler implements ClientCommandHandler, ClientEventHandler {
    private GenericDB currentConnection;
    
    @Override
    public void gotConnected(ClientHandler handler) throws SocketTimeoutException, IOException {
                handler.sendClientMsg("+++++++++++++++++++++++++++++++++++++++++++|");
        handler.sendClientMsg("| Welcome to Caido Query Server v " + QueryServer.version+"      |");
        handler.sendClientMsg("|        Send 'Quit' to exit               |"+currentConnection);
                handler.sendClientMsg("+++++++++++++++++++++++++++++++++++++++++++|\n");
    }

    @Override
    public void handleCommand(ClientHandler handler, String command) {
          GenericDB currentConnection = new GenericDB();
     ...


Exemple: I have 2 computer clients with ip's 192.168.0.5 and 192.168.0.10,
I connect from 192.168.0.5 and currentConnection is not yet defined, I execute a command and currentConnection  will be created for the first time.
When 192.168.0.10 connects will find currentConnection  already created and I was looking for a new instance.

Does Quickserver provide some  functionality to automate this problem?
Or I should keep distinct objects for each client?

Thank you.
Reply all
Reply to author
Forward
0 new messages