Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/lib/network/monitor/network_node.cc @ 9296

Last change on this file since 9296 was 9292, checked in by patrick, 18 years ago

seperating the proxy servers in passive and active

File size: 3.6 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11### File Specific:
12   main-programmer: Patrick Boenzli
13*/
14
15
16#include "network_node.h"
17
18#include "debug.h"
19
20
21/**
22 * constructor
23 */
24NetworkNode::NetworkNode(PeerInfo* pInfo)
25{
26  this->playerNumber = 0;
27  this->peerInfo = pInfo;
28}
29
30
31/**
32 * deconstructor
33 */
34NetworkNode::~NetworkNode()
35{}
36
37
38/**
39 * adds a client
40 */
41void NetworkNode::addClient(PeerInfo* node)
42{
43  this->clientList.push_back(node);
44  this->playerNumber++;
45}
46
47/**
48 * adds a proxy server
49 */
50void NetworkNode::addActiveProxyServer(PeerInfo* node)
51{
52  this->activeProxyServerList.push_back(node);
53  this->playerNumber++;
54}
55
56/**
57 * adds a proxy server
58 */
59void NetworkNode::addPassiveProxyServer(PeerInfo* node)
60{
61  this->passiveProxyServerList.push_back(node);
62}
63
64/**
65 * adds a master server
66 */
67void NetworkNode::addMasterServer(PeerInfo* node)
68{
69  this->masterServerList.push_back(node);
70  this->playerNumber++;
71}
72
73/**
74 * removes a client
75 */
76void NetworkNode::removeClient(PeerInfo* node)
77{
78  std::list<PeerInfo*>::iterator it = this->clientList.begin();
79  for(; it != this->clientList.end(); it++)
80  {
81    if( *it == node)
82    {
83      this->clientList.erase(it);
84      this->playerNumber--;
85      return;
86    }
87  }
88
89  PRINTF(2)("Could not remove client from the list, very strange...");
90}
91
92/**
93 * removes a proxy server
94 */
95void NetworkNode::removeActiveProxyServer(PeerInfo* node)
96{
97  std::list<PeerInfo*>::iterator it = this->activeProxyServerList.begin();
98  for(; it != this->activeProxyServerList.end(); it++)
99  {
100    if( *it == node)
101    {
102      this->activeProxyServerList.erase(it);
103      this->playerNumber--;
104      return;
105    }
106  }
107
108  PRINTF(2)("Could not remove proxy server from the list, very strange...");
109}
110
111/**
112 * removes a proxy server
113 */
114void NetworkNode::removePassiveProxyServer(PeerInfo* node)
115{
116  std::list<PeerInfo*>::iterator it = this->passiveProxyServerList.begin();
117  for(; it != this->passiveProxyServerList.end(); it++)
118  {
119    if( *it == node)
120    {
121      this->passiveProxyServerList.erase(it);
122      return;
123    }
124  }
125
126  PRINTF(2)("Could not remove proxy server from the list, very strange...");
127}
128
129/**
130 * removes a master server
131 */
132void NetworkNode::removeMasterServer(PeerInfo* node)
133{
134  std::list<PeerInfo*>::iterator it = this->masterServerList.begin();
135  for(; it != this->masterServerList.end(); it++)
136  {
137    if( *it == node)
138    {
139      this->masterServerList.erase(it);
140      this->playerNumber--;
141      return;
142    }
143  }
144
145  PRINTF(2)("Could not remove client from the list, very strange...");
146}
147
148
149
150/**
151 * debug function
152 * @param depth: depth in the tree
153 */
154void NetworkNode::debug(int depth)
155{
156  PRINT(0)(" = %s\n", this->peerInfo->getNodeTypeString().c_str());
157
158  PRINT(0)("    master servers: %i\n", this->masterServerList.size());
159  std::list<PeerInfo*>::iterator it = this->masterServerList.begin();
160  for(; it != this->masterServerList.end(); it++)
161  {
162    PRINT(0)("     - ms, id: %i\n", (*it)->userId);
163  }
164
165  PRINT(0)("    proxy servers: %i\n", this->activeProxyServerList.size());
166  it = this->activeProxyServerList.begin();
167  for(; it != this->activeProxyServerList.end(); it++)
168  {
169    PRINT(0)("     - ps, id: %i\n", (*it)->userId);
170  }
171
172  PRINT(0)("    clients: %i\n", this->clientList.size());
173  it = this->clientList.begin();
174  for(; it != this->clientList.end(); it++)
175  {
176    PRINT(0)("     - client, id: %i\n", (*it)->userId);
177  }
178}
179
Note: See TracBrowser for help on using the repository browser.