2019-06-19 17:23:32 -05:00
|
|
|
/*************************************************************************
|
|
|
|
PURPOSE: (Represent Websocket variable server connection.)
|
|
|
|
LIBRARY DEPENDENCIES:
|
2019-08-20 18:14:47 -05:00
|
|
|
( (../src/VariableServerSession.o))
|
|
|
|
|
|
|
|
|
|
|
|
Messages sent from Client to Server
|
|
|
|
================================
|
|
|
|
{ "cmd" : "var_add",
|
|
|
|
"var_name" : <str>
|
|
|
|
}
|
|
|
|
{ "cmd" : "var_pause" }
|
|
|
|
{ "cmd" : "var_unpause" }
|
|
|
|
{ "cmd" : "var_send" }
|
|
|
|
{ "cmd" : "var_clear" }
|
|
|
|
{ "cmd" : "var_exit" }
|
|
|
|
{ "cmd" : "var_cycle",
|
|
|
|
"period" : <int>
|
|
|
|
}
|
|
|
|
|
|
|
|
Messages sent from Server to Client
|
|
|
|
=================================
|
|
|
|
{ "msg_type" : "error",
|
|
|
|
"error_text" : <str>
|
|
|
|
}
|
|
|
|
{ "msg_type" : "var_list"
|
|
|
|
"time" : <double>
|
|
|
|
"values" : []
|
|
|
|
}
|
2019-06-19 17:23:32 -05:00
|
|
|
**************************************************************************/
|
|
|
|
#ifndef WSSESSION_HH
|
|
|
|
#define WSSESSION_HH
|
|
|
|
|
|
|
|
#include <vector>
|
2019-08-16 18:39:45 -05:00
|
|
|
#include <string>
|
2019-06-19 17:23:32 -05:00
|
|
|
#include <mongoose.h>
|
2019-08-19 15:15:33 -05:00
|
|
|
#include "WebSocketSession.hh"
|
2019-08-20 18:14:47 -05:00
|
|
|
#include "VariableServerVariable.hh"
|
2019-06-19 17:23:32 -05:00
|
|
|
|
2019-08-19 16:50:24 -05:00
|
|
|
class VariableServerSession : public WebSocketSession {
|
2019-08-16 18:39:45 -05:00
|
|
|
public:
|
2019-08-19 16:50:24 -05:00
|
|
|
VariableServerSession(struct mg_connection *nc);
|
2019-08-20 18:14:47 -05:00
|
|
|
void stageData(); /* -- base */
|
|
|
|
void sendMessage(); /* -- base */
|
|
|
|
int handleMessage(std::string); /* -- base */
|
2019-08-16 20:16:27 -05:00
|
|
|
|
2019-08-20 18:14:47 -05:00
|
|
|
void setTimeInterval(unsigned int milliseconds);
|
|
|
|
void addVariable(char* vname);
|
|
|
|
void stageVariableValues();
|
|
|
|
void pause();
|
|
|
|
void unpause();
|
|
|
|
void clear();
|
|
|
|
void exit();
|
2019-08-16 20:16:27 -05:00
|
|
|
|
2019-08-16 18:39:45 -05:00
|
|
|
static int bad_ref_int ;
|
|
|
|
|
|
|
|
private:
|
2019-08-19 15:15:33 -05:00
|
|
|
int sendErrorMessage(const char* fmt, ... );
|
2019-08-20 18:14:47 -05:00
|
|
|
REF2* make_error_ref(const char* in_name);
|
|
|
|
double stageTime;
|
|
|
|
std::vector<VariableServerVariable*> sessionVariables;
|
|
|
|
bool cyclicSendEnabled;
|
|
|
|
long long nextTime;
|
|
|
|
long long intervalTimeTics;
|
2019-06-19 17:23:32 -05:00
|
|
|
};
|
|
|
|
#endif
|