public Client(int callcount, String ip, boolean useEvents) {
    this.callcount = callcount;
    if (ip == null) {
      conn = new RemoteClientConnection("localhost", 9090);
    }
    else {
      conn = new RemoteClientConnection(ip, 9090);
    }

    /**
     * Handler for call from server
     */
    conn.setInvokeHandler(this);

    /**
     * Optional events
     */
    if (useEvents) {
      conn.addClientConnectEventListener(new ConnectListener() {
        public void OnConnectEvent(ConnectEvent evt) {
          System.out.println("OnConnectEvent!!!");
        }
      });
      conn.addClientDisconnectEventListener(new DisconnectListener() {
        public void OnDisconnectEvent(DisconnectEvent evt) {
          System.out.println("OnDisconnectEvent");
          try {
            conn.disconnect();
          }
          catch (Exception e) {
          }
        }
      });
      conn.addServerEventListener(new IServerEventListener() {
        public void OnServerEvent(ServerEvent evt) {
          System.out.println("OnServerEvent from " + evt.getSourceName());
        }
      });
    }
  }