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 /// @example testclient/testclientsnakebite.cpp 00024 00025 #include "clientdata.h" 00026 00027 #include "../common/frameworkpacket.h" 00028 #include "clientframework.h" 00029 00030 ClientData::ClientData(ClientFramework *f, ClientPacket * packet) : FrameworkData(packet->readUInt32()),client_framework(f) 00031 { 00032 client_framework->registerData(this); 00033 } 00034 00035 00036 ClientData::~ClientData() 00037 { 00038 client_framework->unregisterData(this); 00039 } 00040 00041 void ClientData::enqueuePacket( ClientPacket * packet ) const 00042 { 00043 // test that the packet is fair enough to send 00044 if(packet->getReceiver() != getFrameworkId() || 00045 packet->getType() < 4) 00046 { 00047 throw new FrameworkError("There is something wrong with the packet you are trying to send"); 00048 } 00049 client_framework->enqueuePacket(packet); 00050 } 00051 00052