Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/lib/network/proxy/proxy_settings.cc @ 9340

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

network stream handshake init remastering and safer proxysettings init

File size: 1.8 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#define DEBUG_MODULE_NETWORK
17
18#include "proxy_settings.h"
19#include "netdefs.h"
20
21#include "loading/load_param.h"
22
23
24using namespace std;
25
26
27ProxySettings* ProxySettings::singletonRef = NULL;
28
29/**
30 * Standard constructor
31 */
32ProxySettings::ProxySettings()
33{
34  /* set the class id for the base object */
35  this->setClassID(CL_PROXY_SETTINGS, "ProxySettings");
36  // suggest a good standard max players value
37  this->maxPlayer = 10;
38}
39
40
41/**
42 * Standard destructor
43 */
44ProxySettings::~ProxySettings()
45{
46  ProxySettings::singletonRef = NULL;
47
48  // remove all unused proxy data again
49  for( int i = 0; i < this->proxies.size(); i++)
50  {
51    IPaddress* ip = this->proxies.back();
52    this->proxies.pop_back();
53    delete ip;
54  }
55}
56
57
58
59/**
60 * load the proxy settings
61 * @param root: the root element of the xml elemnts
62 */
63void ProxySettings::loadProxySettings(const TiXmlElement* root)
64{
65
66  LoadParam(root, "max-player", this, ProxySettings, setMaxPlayer);
67
68  LOAD_PARAM_START_CYCLE(root, element);
69  {
70    element->ToText();
71    // PER-PARTICLE-ATTRIBUTES:
72    LoadParam(root, "proxy-addr", this, ProxySettings, setProxyAddr);
73  }
74  LOAD_PARAM_END_CYCLE(element);
75
76}
77
78
79/**
80 * sets the proxy address to
81 *  @param proxyAddr: the proxy address
82 */
83void ProxySettings::setProxyAddr(const std::string& proxyAddr)
84{
85  IPaddress *ip = new IPaddress;
86
87  SDLNet_ResolveHost( ip, proxyAddr.c_str(), 9999 );
88
89  this->proxies.push_back(ip);
90}
91
92
93
94
95
96
97
Note: See TracBrowser for help on using the repository browser.