2019-06-19 17:23:32 -05:00
|
|
|
/*************************************************************************
|
|
|
|
PURPOSE: (Represent Websocket variable server connection.)
|
|
|
|
LIBRARY DEPENDENCIES:
|
2019-07-18 16:35:29 -05:00
|
|
|
( (../src/WSSession.o))
|
2019-06-19 17:23:32 -05:00
|
|
|
**************************************************************************/
|
|
|
|
#ifndef WSSESSION_HH
|
|
|
|
#define WSSESSION_HH
|
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <mongoose.h>
|
2019-07-18 16:35:29 -05:00
|
|
|
#include "WSSessionVariable.hh"
|
2019-06-19 17:23:32 -05:00
|
|
|
|
|
|
|
inline uint64_t to_nanoseconds(struct timespec* t) {
|
|
|
|
return t->tv_sec * (uint64_t)1000000000L + t->tv_nsec;
|
|
|
|
}
|
|
|
|
|
|
|
|
class WSsession {
|
|
|
|
|
|
|
|
public:
|
|
|
|
WSsession( struct mg_connection *c );
|
|
|
|
void setTimeInterval(unsigned int milliseconds);
|
2019-07-18 16:35:29 -05:00
|
|
|
void addVariable(char* vname);
|
2019-06-19 17:23:32 -05:00
|
|
|
void sendValues();
|
|
|
|
void synchSend(); // This must be called at a frequency greater than or equal to the interval.
|
|
|
|
void pause();
|
|
|
|
void unpause();
|
2019-07-18 16:35:29 -05:00
|
|
|
int emitError(const char* fmt, ... );
|
|
|
|
|
|
|
|
static int bad_ref_int ;
|
2019-06-19 17:23:32 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
WSsession() {}
|
2019-07-18 16:35:29 -05:00
|
|
|
REF2* make_error_ref(const char* in_name);
|
2019-06-19 17:23:32 -05:00
|
|
|
struct mg_connection* connection;
|
2019-07-18 16:35:29 -05:00
|
|
|
std::vector<WSsessionVariable*> sessionVariables;
|
2019-06-19 17:23:32 -05:00
|
|
|
struct timespec lastTime;
|
|
|
|
struct timespec interval;
|
|
|
|
bool enabled;
|
2019-07-18 16:35:29 -05:00
|
|
|
|
2019-06-19 17:23:32 -05:00
|
|
|
};
|
|
|
|
#endif
|