_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
master.h
Go to the documentation of this file.
1 // _________ __ __
2 // / _____// |_____________ _/ |______ ____ __ __ ______
3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
6 // \/ \/ \//_____/ \/
7 // ______________________ ______________________
8 // T H E W A R B E G I N S
9 // Stratagus - A free fantasy real time strategy game engine
10 //
12 //
13 // (c) Copyright 2003-2007 by Tom Zickel and Jimmy Salmon
14 //
15 // This program is free software; you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation; only version 2 of the License.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 // 02111-1307, USA.
28 //
29 
30 #ifndef __MASTER_H__
31 #define __MASTER_H__
32 
34 
35 #include <list>
36 #include "network/netsockets.h"
37 
38 /*----------------------------------------------------------------------------
39 -- Declarations
40 ----------------------------------------------------------------------------*/
41 
42 struct lua_State;
43 
44 // Log data used in metaserver client
45 struct CClientLog {
46  std::string entry; // command itself
47 };
48 
49 
50 // Class representing meta server client structure
52 {
53 public:
54  CMetaClient() : metaSocket(), metaPort(-1), lastRecvState(-1) {}
55  ~CMetaClient();
56  void SetMetaServer(const std::string host, const int port);
57  int Init();
58  void Close();
59  int Send(const std::string cmd);
60  int Recv();
61  int GetLastRecvState() { return lastRecvState; }
62  int GetLogSize() { return events.size(); }
63  CClientLog *GetLastMessage() { return events.back(); }
64 
65 private:
66  CTCPSocket metaSocket;
67  std::string metaHost;
68  int metaPort;
69  std::list <CClientLog *> events;
70  int lastRecvState;
71 };
72 
73 
74 
75 /*----------------------------------------------------------------------------
76 -- Variables
77 ----------------------------------------------------------------------------*/
78 // Metaserver itself
79 extern CMetaClient MetaClient;
80 
82 
83 #endif // !__MASTER_H__
std::string entry
Definition: master.h:46
Definition: netsockets.h:101
Definition: master.h:51
void SetMetaServer(const std::string host, const int port)
Definition: master.cpp:70
CMetaClient()
Definition: master.h:54
int GetLogSize()
Definition: master.h:62
int GetLastRecvState()
Definition: master.h:61
void Close()
Definition: master.cpp:136
~CMetaClient()
Definition: master.cpp:76
CClientLog * GetLastMessage()
Definition: master.h:63
int Send(const std::string cmd)
Definition: master.cpp:151
CMetaClient MetaClient
Definition: master.cpp:58
int Init()
Definition: master.cpp:91
Definition: master.h:45
int Recv()
Definition: master.cpp:165
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.