/****************************************************************************
 * This file is part of the project AqHome.
 * AqHome (c) by 2025 Martin Preuss, all rights reserved.
 *
 * The license for this file can be found in the file COPYING which you
 * should have received along with this file.
 ****************************************************************************/

#ifndef AQHOME_REACT_SERVER_P_H
#define AQHOME_REACT_SERVER_P_H


#include "./server.h"

#include <gwenhywfar/db.h>



/* default values */
#define AQHOME_REACT_DEFAULT_PIDFILE           "/var/run/aqhome-react.pid"
#define AQHOME_REACT_DEFAULT_DATADIR           "/var/lib/aqhome-react"
#define AQHOME_REACT_DEFAULT_VARSFILE          "vars.conf"

#define AQHOME_REACT_DEFAULT_BROKER_PORT       1899
#define AQHOME_REACT_DEFAULT_BROKER_CLIENTID   "react"



typedef struct AQH_REACT_SERVER AQH_REACT_SERVER;
struct AQH_REACT_SERVER {
  AQH_OBJECT *brokerEndpoint;

  GWEN_DB_NODE *dbArgs;
  char *pidFile;
  char *varsFile;

  int timeout;   /* timeout for run e.g. inside valgrind */

  char *brokerAddress;
  int brokerPort;
  char *brokerClientId;

  AQHREACT_UNIT *timerUnit;
  AQHREACT_UNIT *serverVarChangeUnit;
  AQHREACT_UNIT *localVarChangeUnit;
  AQHREACT_UNIT_LIST *unitList;

  AQH_VARS *localVars;

  time_t latestNetworkFileTime;

  time_t timestampBrokerDown;

  int timeoutInSeconds;

};


AQH_REACT_SERVER *AQH_ReactServer_GetServerData(const AQH_OBJECT *o);


#endif


