daily work
This commit is contained in:
parent
3593290f71
commit
fc57caaa6d
|
@ -2,3 +2,4 @@
|
||||||
*.d
|
*.d
|
||||||
hlswmaster
|
hlswmaster
|
||||||
hlswmaster.log
|
hlswmaster.log
|
||||||
|
doc/*
|
||||||
|
|
|
@ -0,0 +1,269 @@
|
||||||
|
# Doxyfile 1.4.4
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Project related configuration options
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
PROJECT_NAME = hlswmaster-ng
|
||||||
|
PROJECT_NUMBER =
|
||||||
|
OUTPUT_DIRECTORY = doc
|
||||||
|
CREATE_SUBDIRS = NO
|
||||||
|
OUTPUT_LANGUAGE = English
|
||||||
|
USE_WINDOWS_ENCODING = NO
|
||||||
|
BRIEF_MEMBER_DESC = YES
|
||||||
|
REPEAT_BRIEF = YES
|
||||||
|
ABBREVIATE_BRIEF = "The $name class" \
|
||||||
|
"The $name widget" \
|
||||||
|
"The $name file" \
|
||||||
|
is \
|
||||||
|
provides \
|
||||||
|
specifies \
|
||||||
|
contains \
|
||||||
|
represents \
|
||||||
|
a \
|
||||||
|
an \
|
||||||
|
the
|
||||||
|
ALWAYS_DETAILED_SEC = NO
|
||||||
|
INLINE_INHERITED_MEMB = NO
|
||||||
|
FULL_PATH_NAMES = YES
|
||||||
|
STRIP_FROM_PATH = /home/razor/projects/linux-c++/hlswmaster-ng/
|
||||||
|
STRIP_FROM_INC_PATH =
|
||||||
|
SHORT_NAMES = NO
|
||||||
|
JAVADOC_AUTOBRIEF = NO
|
||||||
|
MULTILINE_CPP_IS_BRIEF = NO
|
||||||
|
DETAILS_AT_TOP = NO
|
||||||
|
INHERIT_DOCS = YES
|
||||||
|
DISTRIBUTE_GROUP_DOC = NO
|
||||||
|
SEPARATE_MEMBER_PAGES = NO
|
||||||
|
TAB_SIZE = 8
|
||||||
|
ALIASES =
|
||||||
|
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||||
|
OPTIMIZE_OUTPUT_JAVA = NO
|
||||||
|
SUBGROUPING = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Build related configuration options
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
EXTRACT_ALL = YES
|
||||||
|
EXTRACT_PRIVATE = YES
|
||||||
|
EXTRACT_STATIC = YES
|
||||||
|
EXTRACT_LOCAL_CLASSES = YES
|
||||||
|
EXTRACT_LOCAL_METHODS = NO
|
||||||
|
HIDE_UNDOC_MEMBERS = NO
|
||||||
|
HIDE_UNDOC_CLASSES = NO
|
||||||
|
HIDE_FRIEND_COMPOUNDS = NO
|
||||||
|
HIDE_IN_BODY_DOCS = NO
|
||||||
|
INTERNAL_DOCS = NO
|
||||||
|
CASE_SENSE_NAMES = YES
|
||||||
|
HIDE_SCOPE_NAMES = NO
|
||||||
|
SHOW_INCLUDE_FILES = YES
|
||||||
|
INLINE_INFO = YES
|
||||||
|
SORT_MEMBER_DOCS = YES
|
||||||
|
SORT_BRIEF_DOCS = NO
|
||||||
|
SORT_BY_SCOPE_NAME = NO
|
||||||
|
GENERATE_TODOLIST = YES
|
||||||
|
GENERATE_TESTLIST = YES
|
||||||
|
GENERATE_BUGLIST = YES
|
||||||
|
GENERATE_DEPRECATEDLIST= YES
|
||||||
|
ENABLED_SECTIONS =
|
||||||
|
MAX_INITIALIZER_LINES = 30
|
||||||
|
SHOW_USED_FILES = YES
|
||||||
|
SHOW_DIRECTORIES = YES
|
||||||
|
FILE_VERSION_FILTER =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to warning and progress messages
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
QUIET = NO
|
||||||
|
WARNINGS = YES
|
||||||
|
WARN_IF_UNDOCUMENTED = YES
|
||||||
|
WARN_IF_DOC_ERROR = YES
|
||||||
|
WARN_NO_PARAMDOC = NO
|
||||||
|
WARN_FORMAT = "$file:$line: $text"
|
||||||
|
WARN_LOGFILE =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the input files
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
INPUT = /home/razor/projects/linux-c++/hlswmaster-ng
|
||||||
|
FILE_PATTERNS = *.c \
|
||||||
|
*.cc \
|
||||||
|
*.cxx \
|
||||||
|
*.cpp \
|
||||||
|
*.c++ \
|
||||||
|
*.java \
|
||||||
|
*.ii \
|
||||||
|
*.ixx \
|
||||||
|
*.ipp \
|
||||||
|
*.i++ \
|
||||||
|
*.inl \
|
||||||
|
*.h \
|
||||||
|
*.hh \
|
||||||
|
*.hxx \
|
||||||
|
*.hpp \
|
||||||
|
*.h++ \
|
||||||
|
*.idl \
|
||||||
|
*.odl \
|
||||||
|
*.cs \
|
||||||
|
*.php \
|
||||||
|
*.php3 \
|
||||||
|
*.inc \
|
||||||
|
*.m \
|
||||||
|
*.mm \
|
||||||
|
*.dox \
|
||||||
|
*.C \
|
||||||
|
*.CC \
|
||||||
|
*.C++ \
|
||||||
|
*.II \
|
||||||
|
*.I++ \
|
||||||
|
*.H \
|
||||||
|
*.HH \
|
||||||
|
*.H++ \
|
||||||
|
*.CS \
|
||||||
|
*.PHP \
|
||||||
|
*.PHP3 \
|
||||||
|
*.M \
|
||||||
|
*.MM
|
||||||
|
RECURSIVE = NO
|
||||||
|
EXCLUDE =
|
||||||
|
EXCLUDE_SYMLINKS = NO
|
||||||
|
EXCLUDE_PATTERNS =
|
||||||
|
EXAMPLE_PATH =
|
||||||
|
EXAMPLE_PATTERNS = *
|
||||||
|
EXAMPLE_RECURSIVE = NO
|
||||||
|
IMAGE_PATH =
|
||||||
|
INPUT_FILTER =
|
||||||
|
FILTER_PATTERNS =
|
||||||
|
FILTER_SOURCE_FILES = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to source browsing
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
SOURCE_BROWSER = YES
|
||||||
|
INLINE_SOURCES = YES
|
||||||
|
STRIP_CODE_COMMENTS = YES
|
||||||
|
REFERENCED_BY_RELATION = NO
|
||||||
|
REFERENCES_RELATION = NO
|
||||||
|
USE_HTAGS = NO
|
||||||
|
VERBATIM_HEADERS = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the alphabetical class index
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
ALPHABETICAL_INDEX = NO
|
||||||
|
COLS_IN_ALPHA_INDEX = 5
|
||||||
|
IGNORE_PREFIX =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the HTML output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_HTML = YES
|
||||||
|
HTML_OUTPUT = html
|
||||||
|
HTML_FILE_EXTENSION = .html
|
||||||
|
HTML_HEADER =
|
||||||
|
HTML_FOOTER =
|
||||||
|
HTML_STYLESHEET =
|
||||||
|
HTML_ALIGN_MEMBERS = YES
|
||||||
|
GENERATE_HTMLHELP = NO
|
||||||
|
CHM_FILE =
|
||||||
|
HHC_LOCATION =
|
||||||
|
GENERATE_CHI = NO
|
||||||
|
BINARY_TOC = NO
|
||||||
|
TOC_EXPAND = NO
|
||||||
|
DISABLE_INDEX = NO
|
||||||
|
ENUM_VALUES_PER_LINE = 4
|
||||||
|
GENERATE_TREEVIEW = YES
|
||||||
|
TREEVIEW_WIDTH = 250
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the LaTeX output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_LATEX = NO
|
||||||
|
LATEX_OUTPUT = latex
|
||||||
|
LATEX_CMD_NAME = latex
|
||||||
|
MAKEINDEX_CMD_NAME = makeindex
|
||||||
|
COMPACT_LATEX = NO
|
||||||
|
PAPER_TYPE = a4wide
|
||||||
|
EXTRA_PACKAGES =
|
||||||
|
LATEX_HEADER =
|
||||||
|
PDF_HYPERLINKS = NO
|
||||||
|
USE_PDFLATEX = NO
|
||||||
|
LATEX_BATCHMODE = NO
|
||||||
|
LATEX_HIDE_INDICES = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the RTF output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_RTF = NO
|
||||||
|
RTF_OUTPUT = rtf
|
||||||
|
COMPACT_RTF = NO
|
||||||
|
RTF_HYPERLINKS = NO
|
||||||
|
RTF_STYLESHEET_FILE =
|
||||||
|
RTF_EXTENSIONS_FILE =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the man page output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_MAN = NO
|
||||||
|
MAN_OUTPUT = man
|
||||||
|
MAN_EXTENSION = .3
|
||||||
|
MAN_LINKS = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the XML output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_XML = NO
|
||||||
|
XML_OUTPUT = xml
|
||||||
|
XML_SCHEMA =
|
||||||
|
XML_DTD =
|
||||||
|
XML_PROGRAMLISTING = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options for the AutoGen Definitions output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_AUTOGEN_DEF = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the Perl module output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_PERLMOD = NO
|
||||||
|
PERLMOD_LATEX = NO
|
||||||
|
PERLMOD_PRETTY = YES
|
||||||
|
PERLMOD_MAKEVAR_PREFIX =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration options related to the preprocessor
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
ENABLE_PREPROCESSING = YES
|
||||||
|
MACRO_EXPANSION = NO
|
||||||
|
EXPAND_ONLY_PREDEF = NO
|
||||||
|
SEARCH_INCLUDES = YES
|
||||||
|
INCLUDE_PATH =
|
||||||
|
INCLUDE_FILE_PATTERNS =
|
||||||
|
PREDEFINED =
|
||||||
|
EXPAND_AS_DEFINED =
|
||||||
|
SKIP_FUNCTION_MACROS = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration::additions related to external references
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
TAGFILES =
|
||||||
|
GENERATE_TAGFILE =
|
||||||
|
ALLEXTERNALS = NO
|
||||||
|
EXTERNAL_GROUPS = YES
|
||||||
|
PERL_PATH = /usr/bin/perl
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration options related to the dot tool
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
CLASS_DIAGRAMS = YES
|
||||||
|
HIDE_UNDOC_RELATIONS = YES
|
||||||
|
HAVE_DOT = YES
|
||||||
|
CLASS_GRAPH = YES
|
||||||
|
COLLABORATION_GRAPH = YES
|
||||||
|
GROUP_GRAPHS = YES
|
||||||
|
UML_LOOK = NO
|
||||||
|
TEMPLATE_RELATIONS = NO
|
||||||
|
INCLUDE_GRAPH = YES
|
||||||
|
INCLUDED_BY_GRAPH = YES
|
||||||
|
CALL_GRAPH = NO
|
||||||
|
GRAPHICAL_HIERARCHY = YES
|
||||||
|
DIRECTORY_GRAPH = YES
|
||||||
|
DOT_IMAGE_FORMAT = png
|
||||||
|
DOT_PATH =
|
||||||
|
DOTFILE_DIRS =
|
||||||
|
MAX_DOT_GRAPH_WIDTH = 1024
|
||||||
|
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||||
|
MAX_DOT_GRAPH_DEPTH = 1000
|
||||||
|
DOT_TRANSPARENT = NO
|
||||||
|
DOT_MULTI_TARGETS = NO
|
||||||
|
GENERATE_LEGEND = YES
|
||||||
|
DOT_CLEANUP = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration::additions related to the search engine
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
SEARCHENGINE = NO
|
|
@ -0,0 +1,32 @@
|
||||||
|
#include "gamelist.h"
|
||||||
|
|
||||||
|
#define DEFAULT_TIMEOUT 180
|
||||||
|
|
||||||
|
GameList::GameList(Config& conf)
|
||||||
|
{
|
||||||
|
int interval = conf.getInteger("global", "game_timeout", DEFAULT_TIMEOUT);
|
||||||
|
TimerService::registerTimer(new Timer(new CleanupEvent(this), interval));
|
||||||
|
}
|
||||||
|
|
||||||
|
GameList::~GameList()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameList::cleanup()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameList::addGame()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
long GameList::getLastMod()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator<GameEntry>* GameList::createIterator()
|
||||||
|
{
|
||||||
|
return new NullIterator<GameEntry>();
|
||||||
|
}
|
32
gamelist.h
32
gamelist.h
|
@ -1,6 +1,10 @@
|
||||||
#ifndef _GAMELIST_H_
|
#ifndef _GAMELIST_H_
|
||||||
#define _GAMELIST_H_
|
#define _GAMELIST_H_
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "list.h"
|
||||||
|
#include "timerservice.h"
|
||||||
|
|
||||||
class GameEntry {
|
class GameEntry {
|
||||||
public:
|
public:
|
||||||
GameEntry();
|
GameEntry();
|
||||||
|
@ -11,7 +15,7 @@ protected:
|
||||||
GameEntry& operator=(const GameEntry& ge);
|
GameEntry& operator=(const GameEntry& ge);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct in_addr addr;
|
// struct in_addr addr;
|
||||||
int port1;
|
int port1;
|
||||||
int port2;
|
int port2;
|
||||||
int gameid;
|
int gameid;
|
||||||
|
@ -20,12 +24,32 @@ private:
|
||||||
|
|
||||||
class GameList {
|
class GameList {
|
||||||
public:
|
public:
|
||||||
virtual ~GameList() {};
|
GameList(Config& conf);
|
||||||
|
~GameList();
|
||||||
|
|
||||||
virtual void cleanup() {};
|
void cleanup();
|
||||||
|
void addGame();
|
||||||
|
|
||||||
|
long getLastMod();
|
||||||
|
Iterator<GameEntry>* createIterator();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GameList() {}
|
GameList(const GameList& gl);
|
||||||
|
GameList& operator=(const GameList& gl);
|
||||||
|
|
||||||
|
private:
|
||||||
|
class CleanupEvent : public Command {
|
||||||
|
public:
|
||||||
|
CleanupEvent(GameList* gl) : gl(gl) {}
|
||||||
|
~CleanupEvent() {}
|
||||||
|
void execute() { gl->cleanup(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
GameList* gl;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
List<GameEntry> glist;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _GAMELIST_H_
|
#endif // _GAMELIST_H_
|
||||||
|
|
|
@ -2,13 +2,9 @@
|
||||||
#include "netpkt.h"
|
#include "netpkt.h"
|
||||||
#include "gameparser.h"
|
#include "gameparser.h"
|
||||||
|
|
||||||
#define DEFAULT_TIMEOUT 180
|
GameParser::GameParser(RecvQueue& rxQueue, ModuleList& modList, GameList& gameList)
|
||||||
|
: rxQueue(rxQueue), modList(modList), gameList(gameList)
|
||||||
GameParser::GameParser(Config& conf, RecvQueue& rxQueue, ModuleList& modList)
|
|
||||||
: rxQueue(rxQueue), modList(modList)
|
|
||||||
{
|
{
|
||||||
int interval = conf.getInteger("global", "game_timeout", DEFAULT_TIMEOUT);
|
|
||||||
TimerService::registerTimer(new Timer(new CleanupEvent(this), interval));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameParser::~GameParser()
|
GameParser::~GameParser()
|
||||||
|
@ -19,7 +15,7 @@ int GameParser::execute(void* arg)
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
NetPkt* pkt = rxQueue.getPkt();
|
NetPkt* pkt = rxQueue.getPkt();
|
||||||
int ret = modList.parse(pkt, this);
|
int ret = modList.parse(pkt, &gameList);
|
||||||
|
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
case PKT_REJECT:
|
case PKT_REJECT:
|
||||||
|
@ -36,8 +32,3 @@ int GameParser::execute(void* arg)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameParser::cleanup()
|
|
||||||
{
|
|
||||||
// LogSystem::log(LOG_DEBUG, "GameParser::cleanup()");
|
|
||||||
}
|
|
||||||
|
|
20
gameparser.h
20
gameparser.h
|
@ -1,39 +1,27 @@
|
||||||
#ifndef _GAMEPARSER_H_
|
#ifndef _GAMEPARSER_H_
|
||||||
#define _GAMEPARSER_H_
|
#define _GAMEPARSER_H_
|
||||||
|
|
||||||
#include "gamelist.h"
|
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "recvqueue.h"
|
#include "recvqueue.h"
|
||||||
#include "modulelist.h"
|
#include "modulelist.h"
|
||||||
#include "timerservice.h"
|
#include "gamelist.h"
|
||||||
|
|
||||||
class GameParser : public GameList, public Thread {
|
class GameParser : public Thread {
|
||||||
public:
|
public:
|
||||||
GameParser(Config& conf, RecvQueue& rxQueue, ModuleList& modlist);
|
GameParser(RecvQueue& rxQueue, ModuleList& modlist, GameList& gameList);
|
||||||
~GameParser();
|
~GameParser();
|
||||||
|
|
||||||
int execute(void* arg);
|
int execute(void* arg);
|
||||||
|
|
||||||
void cleanup();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GameParser(const GameParser& rp);
|
GameParser(const GameParser& rp);
|
||||||
GameParser& operator=(const GameParser& rp);
|
GameParser& operator=(const GameParser& rp);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class CleanupEvent : public Command {
|
|
||||||
public:
|
|
||||||
CleanupEvent(GameList* sl) : sl(sl) {}
|
|
||||||
~CleanupEvent() {}
|
|
||||||
void execute() { sl->cleanup(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
GameList* sl;
|
|
||||||
};
|
|
||||||
|
|
||||||
RecvQueue& rxQueue;
|
RecvQueue& rxQueue;
|
||||||
ModuleList& modList;
|
ModuleList& modList;
|
||||||
|
GameList& gameList;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _GAMEPARSER_H_
|
#endif // _GAMEPARSER_H_
|
||||||
|
|
|
@ -1,26 +1,21 @@
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "timerservice.h"
|
#include "netpkt.h"
|
||||||
|
|
||||||
#include "gamescanner.h"
|
#include "gamescanner.h"
|
||||||
|
|
||||||
#define DEFAULT_INTERVAL 30
|
#define DEFAULT_INTERVAL 30
|
||||||
|
|
||||||
GameScanner::GameScanner(Config& conf, ModuleList& modList)
|
GameScanner::GameScanner(Config& conf, ModuleList& modList, RecvQueue& rxqueue)
|
||||||
: modList(modList)
|
: modList(modList), rxQueue(rxQueue)
|
||||||
{
|
{
|
||||||
msock = new MultiSock(conf);
|
msock = new MultiSock(conf);
|
||||||
pktCount = new Semaphore(0);
|
|
||||||
|
|
||||||
int interval = conf.getInteger("global", "scan_interval", DEFAULT_INTERVAL);
|
int interval = conf.getInteger("global", "scan_interval", DEFAULT_INTERVAL);
|
||||||
TimerService::registerTimer(new Timer(new ScanEvent(this), interval));
|
TimerService::registerTimer(new Timer(new ScanEvent(this), interval));
|
||||||
}
|
}
|
||||||
|
|
||||||
GameScanner::~GameScanner()
|
GameScanner::~GameScanner()
|
||||||
{
|
{
|
||||||
while (!pktList.isEmpty())
|
|
||||||
delete pktList.get();
|
|
||||||
|
|
||||||
delete pktCount;
|
|
||||||
delete msock;
|
delete msock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,11 +24,7 @@ int GameScanner::execute(void* arg)
|
||||||
while (1) {
|
while (1) {
|
||||||
int fd = msock->waitOnSocket();
|
int fd = msock->waitOnSocket();
|
||||||
NetPkt* pkt = NetPkt::createFromSocket(fd);
|
NetPkt* pkt = NetPkt::createFromSocket(fd);
|
||||||
|
rxQueue.addPkt(pkt);
|
||||||
if (pkt != NULL) {
|
|
||||||
pktList.addTail(pkt);
|
|
||||||
pktCount->post();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -42,9 +33,3 @@ void GameScanner::scan()
|
||||||
{
|
{
|
||||||
modList.scan(msock);
|
modList.scan(msock);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetPkt* GameScanner::getPkt()
|
|
||||||
{
|
|
||||||
pktCount->wait();
|
|
||||||
return pktList.get();
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,27 +1,21 @@
|
||||||
#ifndef _GAMESCANNER_H_
|
#ifndef _GAMESCANNER_H_
|
||||||
#define _GAMESCANNER_H_
|
#define _GAMESCANNER_H_
|
||||||
|
|
||||||
#include "recvqueue.h"
|
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "modulelist.h"
|
#include "modulelist.h"
|
||||||
|
#include "recvqueue.h"
|
||||||
#include "multisock.h"
|
|
||||||
#include "semaphore.h"
|
|
||||||
#include "list.h"
|
|
||||||
#include "netpkt.h"
|
|
||||||
|
|
||||||
#include "timerservice.h"
|
#include "timerservice.h"
|
||||||
|
#include "multisock.h"
|
||||||
|
|
||||||
class GameScanner : public RecvQueue, public Thread {
|
class GameScanner : public Thread {
|
||||||
public:
|
public:
|
||||||
GameScanner(Config& conf, ModuleList& modList);
|
GameScanner(Config& conf, ModuleList& modList, RecvQueue& rxQueue);
|
||||||
~GameScanner();
|
~GameScanner();
|
||||||
|
|
||||||
void scan();
|
|
||||||
|
|
||||||
NetPkt* getPkt();
|
|
||||||
int execute(void* arg);
|
int execute(void* arg);
|
||||||
|
void scan();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GameScanner(const GameScanner& hs);
|
GameScanner(const GameScanner& hs);
|
||||||
|
@ -39,11 +33,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
ModuleList& modList;
|
ModuleList& modList;
|
||||||
|
RecvQueue& rxQueue;
|
||||||
MultiSock* msock;
|
MultiSock* msock;
|
||||||
Semaphore* pktCount;
|
|
||||||
List<NetPkt> pktList;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _SCANNER_H_
|
#endif // _SCANNER_H_
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "recvqueue.h"
|
||||||
#include "gamescanner.h"
|
#include "gamescanner.h"
|
||||||
#include "gameparser.h"
|
#include "gameparser.h"
|
||||||
#include "hlswserver.h"
|
#include "hlswserver.h"
|
||||||
|
@ -80,11 +81,13 @@ int main(int argc, char *argv[])
|
||||||
LogSystem::log(LOG_EVERYTIME, "hlswmaster-ng startup (pid:%d)", getpid());
|
LogSystem::log(LOG_EVERYTIME, "hlswmaster-ng startup (pid:%d)", getpid());
|
||||||
conf.show();
|
conf.show();
|
||||||
|
|
||||||
|
RecvQueue rxQueue;
|
||||||
ModuleList modList(conf);
|
ModuleList modList(conf);
|
||||||
|
GameList gameList(conf);
|
||||||
|
|
||||||
GameScanner scanner(conf, modList);
|
GameScanner scanner(conf, modList, rxQueue);
|
||||||
GameParser parser(conf, scanner, modList);
|
GameParser parser(rxQueue, modList, gameList);
|
||||||
HlswServer server(conf, parser);
|
HlswServer server(conf);
|
||||||
|
|
||||||
// modList.reg(new ModHalfLife());
|
// modList.reg(new ModHalfLife());
|
||||||
// modList.reg(new ModQ3Engine());
|
// modList.reg(new ModQ3Engine());
|
||||||
|
|
|
@ -25,7 +25,7 @@ HlswServer::HlswPacket::~HlswPacket()
|
||||||
delete next;
|
delete next;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HlswServer::HlswPacket::addGame(void* ptr)
|
bool HlswServer::HlswPacket::addGame(GameEntry* ge)
|
||||||
{
|
{
|
||||||
if (count < 140) {
|
if (count < 140) {
|
||||||
count++;
|
count++;
|
||||||
|
@ -47,7 +47,7 @@ void HlswServer::HlswPacket::send(int socket, struct sockaddr_in* dst)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HlswServer::HlswServer(Config& conf, GameList& slist)
|
HlswServer::HlswServer(Config& conf)
|
||||||
{
|
{
|
||||||
struct sockaddr_in dst;
|
struct sockaddr_in dst;
|
||||||
const char *ip;
|
const char *ip;
|
||||||
|
@ -108,13 +108,15 @@ int HlswServer::execute(void* arg)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void HlswServer::rebuild(GameList& glist) {
|
||||||
HlswPacket* newlist;
|
Iterator<GameEntry>* it = glist.createIterator();
|
||||||
|
|
||||||
|
HlswPacket* newlist = NULL;
|
||||||
while (it->hasNext()) {
|
while (it->hasNext()) {
|
||||||
Data* d = it->next();
|
GameEntry* d = it->next();
|
||||||
if (!newlist || !newlist->add(d))
|
if (!newlist || !newlist->addGame(d)) {
|
||||||
newlist = new HlswPacket(newlist);
|
newlist = new HlswPacket(newlist);
|
||||||
newlist->add(d);
|
newlist->addGame(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,5 +126,5 @@ int HlswServer::execute(void* arg)
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
|
||||||
delete oldlist;
|
delete oldlist;
|
||||||
*/
|
delete it;
|
||||||
|
}
|
||||||
|
|
|
@ -10,11 +10,13 @@
|
||||||
|
|
||||||
class HlswServer : public Thread {
|
class HlswServer : public Thread {
|
||||||
public:
|
public:
|
||||||
HlswServer(Config& conf, GameList& slist);
|
HlswServer(Config& conf);
|
||||||
~HlswServer();
|
~HlswServer();
|
||||||
|
|
||||||
int execute(void* arg);
|
int execute(void* arg);
|
||||||
|
|
||||||
|
void rebuild(GameList& glist);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HlswServer(const HlswServer& hs);
|
HlswServer(const HlswServer& hs);
|
||||||
HlswServer& operator=(const HlswServer& hs);
|
HlswServer& operator=(const HlswServer& hs);
|
||||||
|
@ -25,7 +27,7 @@ private:
|
||||||
HlswPacket(HlswPacket* next);
|
HlswPacket(HlswPacket* next);
|
||||||
~HlswPacket();
|
~HlswPacket();
|
||||||
|
|
||||||
bool addGame(void* ptr);
|
bool addGame(GameEntry* ge);
|
||||||
void send(int socket, struct sockaddr_in* dst);
|
void send(int socket, struct sockaddr_in* dst);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
#include "recvqueue.h"
|
||||||
|
|
||||||
|
RecvQueue::RecvQueue()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
RecvQueue::~RecvQueue()
|
||||||
|
{
|
||||||
|
while (!pktList.isEmpty())
|
||||||
|
delete pktList.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RecvQueue::addPkt(NetPkt* pkt)
|
||||||
|
{
|
||||||
|
if (pkt != NULL) {
|
||||||
|
pktList.addTail(pkt);
|
||||||
|
pktCount->post();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NetPkt* RecvQueue::getPkt()
|
||||||
|
{
|
||||||
|
pktCount->wait();
|
||||||
|
return pktList.get();
|
||||||
|
}
|
16
recvqueue.h
16
recvqueue.h
|
@ -2,14 +2,24 @@
|
||||||
#define _RECVQUEUE_H_
|
#define _RECVQUEUE_H_
|
||||||
|
|
||||||
#include "netpkt.h"
|
#include "netpkt.h"
|
||||||
|
#include "semaphore.h"
|
||||||
|
#include "list.h"
|
||||||
|
|
||||||
class RecvQueue {
|
class RecvQueue {
|
||||||
public:
|
public:
|
||||||
virtual ~RecvQueue() {};
|
RecvQueue();
|
||||||
virtual NetPkt* getPkt() =0;
|
~RecvQueue();
|
||||||
|
|
||||||
|
void addPkt(NetPkt* pkt);
|
||||||
|
NetPkt* getPkt();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RecvQueue() {};
|
RecvQueue(const RecvQueue& rq);
|
||||||
|
RecvQueue& operator=(const RecvQueue& rq);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Semaphore* pktCount;
|
||||||
|
List<NetPkt> pktList;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _RECVQUEUE_H_
|
#endif // _RECVQUEUE_H_
|
||||||
|
|
|
@ -5,10 +5,11 @@
|
||||||
|
|
||||||
class Semaphore {
|
class Semaphore {
|
||||||
public:
|
public:
|
||||||
Semaphore(int i) { sem_init(&s, 0, i); }
|
Semaphore() { sem_init(&s, 0, 0); }
|
||||||
~Semaphore() { sem_destroy(&s); }
|
Semaphore(int i) { sem_init(&s, 0, i); }
|
||||||
void wait() { sem_wait(&s); }
|
~Semaphore() { sem_destroy(&s); }
|
||||||
void post() { sem_post(&s); }
|
void wait() { sem_wait(&s); }
|
||||||
|
void post() { sem_post(&s); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Semaphore(const Semaphore& s);
|
Semaphore(const Semaphore& s);
|
||||||
|
|
Loading…
Reference in New Issue