/*************************************************************************** * The contents of this file are subject to the Mozilla Public * * License Version 1.1 (the "License"); you may not use this file * * except in compliance with the License. You may obtain a copy of * * the License at http://www.mozilla.org/MPL/ * * * * Software distributed under the License is distributed on an "AS * * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * * implied. See the License for the specific language governing * * rights and limitations under the License. * * * * The Original Code is Game Network Framework (GaNeF). * * * * The Initial Developers of the Original Code are * * Lars Langer and Emanuel Greisen * * Copyright (C) 2005. Lars Langer & Emanuel Greisen * * All Rights Reserved. * * * * Contributor(s): * * none yet.... * * * ***************************************************************************/ #ifndef TESTSERVERFRAMEWORK_H #define TESTSERVERFRAMEWORK_H #include "../Ganef/server/serverframework.h" #include "testserversnakebite.h" #include <vector> /** * A simple client with head/tail of his/her snake. */ class TestClient : public Client { public: TestServerSnakeBite * m_snake_head; TestServerSnakeBite * m_snake_tail; public: TestClient(ServerFramework * fw, const ipaddress &addr, int port) : Client(fw, addr, port),m_snake_head(0),m_snake_tail(0){}; }; /** * @cond EXCLUDEDTESTSOURCES * This is just a test framework * @author Lars Langer and Emanuel Greisen */ class TestServerFramework : public ServerFramework { private: std::vector<TestServerSnakeBite *> snakes; void addTestServerSnakeBite(TestServerSnakeBite * bite); public: TestServerFramework(); ~TestServerFramework(); protected: // These method should be implemented on the GameServer /// This method should write it's reply in the reply-packet, /// and return true or false depending on wether it want's us to continue the handshaking. virtual bool onInitialHandshake(ServerPacket * handshake, ServerPacket * reply); /// This method will be invoked when a new client has passed the handshaking-phase. virtual void onClientConnected(Client * client); /// This method will be invoked when a client has timed out. virtual void onClientDisconnected(Client * client); /// This method should return some dirivative of the Client-class. virtual Client * createClient(const ipaddress & addr, int port); public: void mainLoop(); }; #endif /// @endcond