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:
|
2019-08-13 16:27:03 -05:00
|
|
|
WSsession( struct mg_connection *nc);
|
2019-06-19 17:23:32 -05:00
|
|
|
void setTimeInterval(unsigned int milliseconds);
|
2019-07-18 16:35:29 -05:00
|
|
|
void addVariable(char* vname);
|
2019-08-13 16:27:03 -05:00
|
|
|
void stageValuesSynchronously();
|
|
|
|
void stageValues();
|
2019-06-19 17:23:32 -05:00
|
|
|
void sendValues();
|
|
|
|
void pause();
|
|
|
|
void unpause();
|
2019-07-22 13:35:43 -05:00
|
|
|
void clear();
|
|
|
|
void exit();
|
2019-08-13 16:27:03 -05:00
|
|
|
int handle_msg (const char* client_msg);
|
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-08-13 16:27:03 -05:00
|
|
|
bool cyclicSendEnabled;
|
|
|
|
double stageTime;
|
|
|
|
bool valuesStaged;
|
|
|
|
long long nextTime;
|
|
|
|
long long intervalTimeTics;
|
|
|
|
|
2019-07-18 16:35:29 -05:00
|
|
|
|
2019-06-19 17:23:32 -05:00
|
|
|
};
|
|
|
|
#endif
|