-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclusterchat.cc
75 lines (54 loc) · 1.95 KB
/
clusterchat.cc
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//***************************************************************************
// File clusterchat.hpp
// Date 23.07.17 - #1
// Copyright (c) 2017-2017 s710 (s710 (at) posteo (dot) de). All rights reserved.
// --------------------------------------------------------------------------
// Ark ClusterChat / ClusterChat class
//***************************************************************************
#include <stdio.h>
#include "clusterchat.hpp"
//***************************************************************************
// class ClusterChat
//***************************************************************************
// ctor/dtor
//***************************************************************************
ClusterChat::ClusterChat()
{
}
ClusterChat::~ClusterChat()
{
for (std::list<RConThread*>::iterator it= threads.begin(); it != threads.end(); ++it)
delete *it;
}
//***************************************************************************
// init
//***************************************************************************
int ClusterChat::init(std::list<ServerConfig*>* configs)
{
int res= success;
for (std::list<ServerConfig*>::iterator it= configs->begin(); it != configs->end(); ++it)
{
RConThread* thread = new RConThread(&threads);
ServerConfig* cfg= *it;
res= thread->start(120, cfg->host.c_str(), cfg->port, cfg->password.c_str(), cfg->title.c_str());
if (res)
{
thread->stop();
delete thread;
shutdown();
return res;
}
threads.push_back(thread);
}
return res;
}
//***************************************************************************
// shutdown
//***************************************************************************
int ClusterChat::shutdown()
{
printf("ClusterChat: Stopping worker threads ...\n");
for (std::list<RConThread*>::iterator it= threads.begin(); it != threads.end(); ++it)
(*it)->stop();
return done;
}