From: <wol...@us...> - 2004-04-17 17:19:28
|
Update of /cvsroot/csp/APPLICATIONS/CSPSim/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8579 Modified Files: CSPSim.h DynamicObject.h Added Files: Networking.h Log Message: Changes for networking --- NEW FILE: Networking.h --- // Combat Simulator Project - FlightSim Demo // Copyright (C) 2002 The Combat Simulator Project // http://csp.sourceforge.net // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** * @file Networking.h * */ #ifndef __NETWORKING_H__ #define __NETWORKING_H__ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <errno.h> #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <arpa/inet.h> #include <SimData/Vector3.h> class NetworkMessage { protected: unsigned char * m_Buf; unsigned char * m_PayloadBuf; unsigned short m_BufferLen; unsigned short m_MessageType; unsigned short m_PayloadLen; bool m_Initialized; static unsigned short magicNumber; static unsigned short m_HeaderLen; public: NetworkMessage(); virtual ~NetworkMessage(); bool initialize(unsigned short type, unsigned short payloadLength); unsigned short getType(); void * getBufferPtr(); void * getPayloadPtr(); unsigned short getBufferLen(); unsigned short getPayloadLen(); unsigned short getHeaderLen(); bool isInitialized(); bool isHeaderValid(); }; class NetworkMessagePool { }; class ObjectUpdateMessage : public NetworkMessage { public: ObjectUpdateMessage(unsigned int id, simdata::Vector3 position, simdata::Vector3 velocity); }; class NetworkNode { public: NetworkNode(); char * getNetworkName(); }; class NetworkSocket { int m_sockfd; struct sockaddr_in * m_servaddr; public: NetworkSocket(NetworkNode * node, short port); int sendto(NetworkMessage * message); }; class NetworkMessenger { NetworkMessenger(); }; class NetworkBroadcaster { short m_server_port; NetworkNode * m_node; NetworkSocket * m_socket; public: NetworkBroadcaster(); void sendMessage( int NodeID, NetworkMessage * message); }; class NetworkListener { public: NetworkListener(); void receiveAvailableMessages(); }; #endif Index: CSPSim.h =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Include/CSPSim.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** CSPSim.h 20 Oct 2003 00:23:22 -0000 1.17 --- CSPSim.h 17 Apr 2004 17:19:19 -0000 1.18 *************** *** 60,63 **** --- 60,64 ---- class EventMapIndex; class PyConsole; + class NetworkBroadcaster; *************** *** 88,92 **** simdata::SimDate & getCurrentTime() { return m_CurrentTime; } simdata::SimTime const & getFrameRate() const{ return m_FrameRate; } ! void setActiveObject(simdata::Ref<DynamicObject> object); simdata::Ref<DynamicObject> getActiveObject() const; --- 89,94 ---- simdata::SimDate & getCurrentTime() { return m_CurrentTime; } simdata::SimTime const & getFrameRate() const{ return m_FrameRate; } ! simdata::SimTime const & getElapsedTime() const { return m_ElapsedTime; } ! void setActiveObject(simdata::Ref<DynamicObject> object); simdata::Ref<DynamicObject> getActiveObject() const; *************** *** 175,178 **** --- 177,185 ---- osg::ref_ptr<PyConsole> m_Console; simdata::Ref<PyShell> m_Shell; + + /** + * The network layer + */ + NetworkBroadcaster * m_NetworkBroadcaster; #ifndef CSP_OSG_094 Index: DynamicObject.h =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Include/DynamicObject.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** DynamicObject.h 20 Oct 2003 00:23:22 -0000 1.13 --- DynamicObject.h 17 Apr 2004 17:19:19 -0000 1.14 *************** *** 2,16 **** // Copyright (C) 2002 The Combat Simulator Project // http://csp.sourceforge.net ! // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. ! // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. ! // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software --- 2,16 ---- // Copyright (C) 2002 The Combat Simulator Project // http://csp.sourceforge.net ! // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. ! // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. ! // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software *************** *** 35,38 **** --- 35,40 ---- #include "SystemsModel.h" + #include "Networking.h" + namespace osgParticle { *************** *** 98,101 **** --- 100,105 ---- void setVehicleCore(SystemsModel::Ref); + + protected: void setAir(bool flag) { setFlags(F_AIR, flag); } *************** *** 176,179 **** --- 180,185 ---- virtual void setDataRecorder(DataRecorder *recorder); + virtual NetworkMessage * getUpdateMessage(); + virtual void putUpdateMessage(NetworkMessage* message); protected: |