/Desktop/MGS-MultithreadedGameServer/Server.h

Vai alla documentazione di questo file.
00001 //
00002 // File: Server.h
00003 // Created by: <Detro /> aka Ivan De Marino 
00004 // <detro@mandolinux.org, demarino@studenti.unina.it, demarino@na.astro.it>
00005 // Created on: Sun Oct 24 13:14:11 2004
00006 //
00007 
00008 #ifndef _SERVER_H_
00009 #define _SERVER_H_
00010 
00011 #include <list>
00012 #include <vector>
00013 #include <cc++/socket.h>
00014 #include <iostream>
00015 #include <sys/types.h>
00016 #include <dirent.h>
00017 #include "ConnectionHandler.h"
00018 #include "Game.h"
00019 #include "TFactory.h"
00020 #include "TFactoryException.h"
00021 
00022 #ifdef  CCXX_NAMESPACES
00023 using namespace std;
00024 using namespace ost;
00025 #endif
00026 
00027 /**
00028  * @class Server Server.h
00029  * Server per MGS.
00030  * Classe principale di MGS. Ha il compito di:
00031  * <ul>
00032  *    <li>
00033  *       mettersi in ascolto su una porta 
00034  *       (<b><i>passive mode socket</i></b>)
00035  *    </li>
00036  *    <li>
00037  *        creare un <b>"handler" (<i>@c ConnectionHandler</i>)</b> 
00038  *        all'arrivo di una nuova connessione
00039  *    </li>
00040  *    <li>
00041  *       assegnare la connessione all'handler appena creato affinche'
00042  *       la gestisca
00043  *    </li>
00044  * </ul> */
00045 class Server : public TCPSocket {
00046    public:
00047       Server(const InetAddress &, const tpport_t, const string);
00048       void run(const timeout_t = TIMEOUT_INF);
00049       virtual ~Server(void);
00050    
00051    private:
00052       /** Pool (lista) di Handler (<code>ConnectionHandler</code>)
00053        * di Connessioni attive */
00054       list <ConnectionHandler *> connHandPool;
00055       /** Vettore dei @c Game istanziati */
00056       vector <Game *> activeGames;
00057       /** 
00058        * Vettore dei @c Game disponibili (caricati a Run-Time come Plug-In).
00059        * Il Vettore e' costituito di coppie: (<Nome Game>, <Factory Game>). */
00060       vector < pair< string, TFactory<Game*> *> *> availableGames;
00061       /** Path della Directory contenente i Plug-In dei Game */
00062       string pluginGameDirPath;
00063    
00064       bool onAccept(const InetHostAddress &, const tpport_t);
00065       void loadPlugInGames(void);
00066       static int SharedObjectLibrarySelector(const struct dirent *);
00067 };
00068 
00069 
00070 #endif   //_SERVER_H_

Generato il Sun Nov 28 13:27:03 2004 per MGS - Multithreaded Game Server da doxygen 1.3.4