You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.4 KiB
58 lines
1.4 KiB
#pragma once
|
|
|
|
#include "ofMain.h"
|
|
#include "ofxNetwork.h"
|
|
#include "Request.h"
|
|
#include <unordered_map>
|
|
#include <chrono>
|
|
#include "ofxOsc.h"
|
|
#include "../vp/VP.h"
|
|
|
|
#define OSC_HOST "127.0.0.1"
|
|
#define OSC_PORT 9002
|
|
|
|
struct ClientInfo {
|
|
float value;
|
|
std::string ip_address;
|
|
};
|
|
|
|
class Server{
|
|
public:
|
|
Server(int _port, Embedding _embedding, VP _tree, bool debug, std::string _http_ip, int _http_port, std::string _http_page)
|
|
: port(_port), embedding(_embedding), tree(_tree), debug(debug), http_ip(_http_ip), http_port(_http_port), http_page(_http_page) {}
|
|
|
|
void start();
|
|
void update();
|
|
void addOrUpdateClient(int client_id, float value, const std::string& ip_address);
|
|
void printClients();
|
|
void updateEmbedding();
|
|
void checkActivity();
|
|
void sendHttpRequest();
|
|
void sendOSCMessage();
|
|
std::vector<std::vector<double>> generateRandomVectors(int count, int dimension);
|
|
|
|
|
|
|
|
int port;
|
|
ofxTCPServer server;
|
|
std::unordered_map<int, ClientInfo> clients;
|
|
bool debug;
|
|
bool is_active;
|
|
Embedding embedding;
|
|
|
|
Request http;
|
|
std::string http_ip;
|
|
int http_port;
|
|
std::string http_page;
|
|
VPResp vp_resp;
|
|
|
|
private:
|
|
Embedding previous_embedding;
|
|
std::chrono::time_point<std::chrono::steady_clock> last_change_time;
|
|
|
|
ofxOscSender osc_sender;
|
|
std::string past_audio_file;
|
|
|
|
/* vp tree */
|
|
VP tree;
|
|
};
|