Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages | Examples

testserverframework.h

00001 /***************************************************************************
00002  * The contents of this file are subject to the Mozilla Public             *
00003  * License Version 1.1 (the "License"); you may not use this file          *
00004  * except in compliance with the License. You may obtain a copy of         *
00005  * the License at http://www.mozilla.org/MPL/                              *
00006  *                                                                         *
00007  * Software distributed under the License is distributed on an "AS         *
00008  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or              *
00009  * implied. See the License for the specific language governing            *
00010  * rights and limitations under the License.                               *
00011  *                                                                         *
00012  * The Original Code is Game Network Framework (GaNeF).                    *
00013  *                                                                         *
00014  * The Initial Developers of the Original Code are                         *
00015  * Lars Langer and Emanuel Greisen                                         *
00016  * Copyright (C) 2005. Lars Langer & Emanuel Greisen                       *
00017  * All Rights Reserved.                                                    *
00018  *                                                                         *
00019  * Contributor(s):                                                         *
00020  *   none yet....                                                          *
00021  *                                                                         *
00022  ***************************************************************************/
00023 #ifndef TESTSERVERFRAMEWORK_H
00024 #define TESTSERVERFRAMEWORK_H
00025 
00026 #include "../Ganef/server/serverframework.h"
00027 
00028 #include "testserversnakebite.h"
00029 
00030 #include <vector>
00031 
00032 
00033 /**
00034  * A simple client with head/tail of his/her snake.
00035  */
00036 class TestClient : public Client
00037 {
00038 public:
00039    TestServerSnakeBite * m_snake_head;
00040    TestServerSnakeBite * m_snake_tail;
00041 public:
00042    TestClient(ServerFramework * fw, const ipaddress &addr, int port) : Client(fw, addr, port),m_snake_head(0),m_snake_tail(0){};
00043 };
00044 
00045 /**
00046  * @cond EXCLUDEDTESTSOURCES
00047  * This is just a test framework
00048  * @author Lars Langer and Emanuel Greisen
00049  */
00050 class TestServerFramework : public ServerFramework
00051 {
00052 private:
00053    std::vector<TestServerSnakeBite *> snakes;
00054    void addTestServerSnakeBite(TestServerSnakeBite * bite);
00055 
00056 public:
00057    TestServerFramework();
00058    ~TestServerFramework();
00059 
00060 protected: // These method should be implemented on the GameServer
00061    /// This method should write it's reply in the reply-packet,
00062    /// and return true or false depending on wether it want's us to continue the handshaking.
00063    virtual bool onInitialHandshake(ServerPacket * handshake, ServerPacket * reply);
00064    /// This method will be invoked when a new client has passed the handshaking-phase.
00065    virtual void onClientConnected(Client * client);
00066    /// This method will be invoked when a client has timed out.
00067    virtual void onClientDisconnected(Client * client);
00068    /// This method should return some dirivative of the Client-class.
00069    virtual Client * createClient(const ipaddress & addr, int port);
00070 
00071 public:
00072    void mainLoop();
00073 };
00074 
00075 #endif
00076 /// @endcond

Generated on Mon Feb 6 12:24:50 2006 for Ganef by  doxygen 1.4.4