-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkraken.public.cpp
More file actions
54 lines (43 loc) · 1.26 KB
/
kraken.public.cpp
File metadata and controls
54 lines (43 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "kraken.hpp"
void* Kraken::execTask(void *arg){
static int execRunning = false;
if(execRunning == true){ return NULL; }
Kraken *instance = static_cast<Kraken *>(arg);
execRunning = true;
instance->run();
execRunning = false;
return NULL;
}
Kraken::Kraken(std::string ns, std::string identifier, int port=4101){
this->port = port;
this->ns = ns;
this->identifier = identifier;
this->heartbeatIntervalInSeconds = 60;
this->socksrv_inaddr_anyv4 = -1;
this->socksrv_inaddr_anyv6 = -1;
this->socksrv_mcastv4 = -1;
this->socksrv_mcastv6 = -1;
this->v4McastIp = std::string("239.255.146.253");
this->v6McastIp = std::string("FF02:0:0:0:0:0:0:1");
this->keeprunning = true;
this->isrunning = false;
}
Kraken::~Kraken(){
this->keeprunning = false;
pthread_join(this->th, NULL);
}
Kraken& Kraken::start(){
pthread_create(&this->th, NULL, Kraken::execTask, (void*) this);
return *this;
}
int Kraken::getPort(){ return this->port; }
Kraken& Kraken::setPort(int port){
this->port = port;
return *this;
}
void Kraken::subscribe(Kraken::ISubscriber *ref){
this->subscribers.insert(ref);
}
void Kraken::unsubscribe(Kraken::ISubscriber *ref){
this->subscribers.erase(ref);
}