From: <he...@us...> - 2010-01-01 22:01:12
|
Revision: 132 http://simspark.svn.sourceforge.net/simspark/?rev=132&view=rev Author: hedayat Date: 2010-01-01 22:01:05 +0000 (Fri, 01 Jan 2010) Log Message: ----------- Fixed 32bit-64bit compatibility issue. Message length is always transmitted in 4bytes. Some code cleanup Put ~/.simspark as the first resource location to be searched Add ProxyServer classes (to be used as a syncronization proxy between agents and server) Modified Paths: -------------- trunk/spark/ChangeLog trunk/spark/lib/oxygen/CMakeLists.txt trunk/spark/lib/oxygen/simulationserver/netmessage.cpp trunk/spark/lib/oxygen/simulationserver/simcontrolnode.h trunk/spark/lib/zeitgeist/fileserver/fileserver.cpp trunk/spark/lib/zeitgeist/zeitgeist.cpp Added Paths: ----------- trunk/spark/lib/oxygen/proxyserver/ trunk/spark/lib/oxygen/proxyserver/agentproxy.cpp trunk/spark/lib/oxygen/proxyserver/agentproxy.h trunk/spark/lib/oxygen/proxyserver/agentproxy_c.cpp trunk/spark/lib/oxygen/proxyserver/proxyserver.cpp trunk/spark/lib/oxygen/proxyserver/proxyserver.h trunk/spark/lib/oxygen/proxyserver/proxyserver_c.cpp Modified: trunk/spark/ChangeLog =================================================================== --- trunk/spark/ChangeLog 2009-12-29 19:52:44 UTC (rev 131) +++ trunk/spark/ChangeLog 2010-01-01 22:01:05 UTC (rev 132) @@ -1,3 +1,27 @@ +2010-01-01 Hedayat Vatankhah <he...@gr...> + + * lib/oxygen/proxyserver/proxyserver.h: + * lib/oxygen/proxyserver/proxyserver.cpp: + * lib/oxygen/proxyserver/proxyserver_c.cpp: + * lib/oxygen/proxyserver/agentproxy.h: + * lib/oxygen/proxyserver/agentproxy.cpp: + * lib/oxygen/proxyserver/agentproxy_c.cpp: + - starting the proxy server implementation + +2009-12-31 Hedayat Vatankhah <he...@gr...> + + * lib/oxygen/simulationserver/netmessage.cpp: + - payload length is now always 32bit on all platforms, to make the + protocol platform independent (fixed 32bit/64bit compatibility issue) + + * lib/zeitgeist/fileserver/fileserver.cpp: + * lib/zeitgeist/zeitgeist.cpp (Zeitgeist::RunInitScript): + - add ~/.simspark as the first resource location, so that it is the first + address examined after the current directory + + * lib/oxygen/simulationserver/simcontrolnode.h: + - remove unused mCond member variable + 2009-12-29 Hedayat Vatankhah <he...@gr...> * lib/zeitgeist/zeitgeist.cpp (Zeitgeist::RunInitScript): Modified: trunk/spark/lib/oxygen/CMakeLists.txt =================================================================== --- trunk/spark/lib/oxygen/CMakeLists.txt 2009-12-29 19:52:44 UTC (rev 131) +++ trunk/spark/lib/oxygen/CMakeLists.txt 2010-01-01 22:01:05 UTC (rev 132) @@ -71,6 +71,8 @@ monitorserver/monitoritem.h monitorserver/custommonitor.h monitorserver/monitorcmdparser.h + proxyserver/agentproxy.h + proxyserver/proxyserver.h ) if(SPADES_FOUND) set(oxygen_LIB_HDRS @@ -204,6 +206,10 @@ monitorserver/custommonitor_c.cpp monitorserver/monitorcmdparser.cpp monitorserver/monitorcmdparser_c.cpp + proxyserver/agentproxy.cpp + proxyserver/agentproxy_c.cpp + proxyserver/proxyserver.cpp + proxyserver/proxyserver_c.cpp ) if(SPADES_FOUND) set(oxygen_LIB_SRCS Added: trunk/spark/lib/oxygen/proxyserver/agentproxy.cpp =================================================================== --- trunk/spark/lib/oxygen/proxyserver/agentproxy.cpp (rev 0) +++ trunk/spark/lib/oxygen/proxyserver/agentproxy.cpp 2010-01-01 22:01:05 UTC (rev 132) @@ -0,0 +1,189 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Thu Dec 31 2009 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2004-2009 RoboCup Soccer Server 3D Maintenance Group + $Id$ + + 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; version 2 of the License. + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#include "agentproxy.h" +#include <rcssnet/exception.hpp> +#include <zeitgeist/logserver/logserver.h> +#include <oxygen/simulationserver/netcontrol.h> + +#ifdef HAVE_SYS_SOCKET_H +#include <sys/socket.h> +#endif + +using namespace oxygen; +using namespace zeitgeist; +using namespace std; +using namespace rcss::net; +using boost::shared_ptr; + +AgentProxy::AgentProxy(int cycleMillisecs) : Node(), + mCycleMillisecs(cycleMillisecs), mFinished(false), + mAgentBuffer(new NetBuffer) +{ +} + +AgentProxy::~AgentProxy() +{ +} + +void AgentProxy::Start(boost::shared_ptr<rcss::net::Socket> agentSocket, + rcss::net::Addr serverAddress) +{ + try + { + mAgentSocket = agentSocket; + mServerSocket = NetControl::CreateSocket(NetControl::ST_TCP); + if (!mServerSocket) + { + mFinished = true; + return; + } + GetLog()->Normal() << "(AgentProxy) '" << GetName() << "'connecting to " + << serverAddress << "\n"; + mServerSocket->connect(serverAddress); + if (mServerSocket->isConnected()) + { + cout << "(AgentProxy) '" << GetName() << "' connected successfully" + << endl; + } + + // assure that a NetMessage object is registered + mNetMessage = FindChildSupportingClass<NetMessage>(); + if (mNetMessage.get() == 0) + { + mNetMessage = shared_ptr<NetMessage>(new NetMessage()); + } + + mAgentConnectionThread = boost::thread( + &AgentProxy::AgentConnectionHandler, this); + mServerConnectionThread = boost::thread( + &AgentProxy::ServerConnectionHandler, this); + return; + } + catch (BindErr error) + { + GetLog()->Error() << "(AgentProxy) '" << GetName() + << "' failed to bind socket with '" << error.what() << "'" + << endl; + } + catch (ConnectErr error) + { + GetLog()->Error() << "(AgentProxy) '" << GetName() + << "' connection failed with: '" << error.what() << "'" << endl; + } + + // executed on error + mServerSocket->close(); + mFinished = true; +} + +void AgentProxy::Stop() +{ + mFinished = true; + mServerConnectionThread.join(); +} + +void AgentProxy::ServerConnectionHandler() +{ + string syncMsg("(sync)"); + string servermsg, agentmsg; + boost::system_time cycleFinishTime = boost::get_system_time() + + boost::posix_time::milliseconds(mCycleMillisecs); + shared_ptr<NetBuffer> netbuf(new NetBuffer); + TRawBuffer recvbuf; + + mNetMessage->PrepareToSend(syncMsg); + while (!mFinished) + { + try + { + servermsg.clear(); + boost::thread::sleep(cycleFinishTime); + + boost::mutex::scoped_lock agentBufLock(mAgentBufferMutex); + while (!mAgentBuffer->IsEmpty() && + mNetMessage->Extract(mAgentBuffer, agentmsg)) + { + mServerSocket->send(agentmsg.data(), agentmsg.size()); + } + agentBufLock.unlock(); + + mServerSocket->send(syncMsg.data(), syncMsg.size()); + do + { + int retval = mServerSocket->recv(mCycleMillisecs, + recvbuf.data(), recvbuf.size()); + if (retval > 0) + netbuf->AddFragment(string(recvbuf.data(), recvbuf.size())); + else if (retval < 0 && errno == EAGAIN) + break; + else + { + GetLog()->Error() + << "(AgentProxy) ERROR: '" << GetName() + << "' recv returned error on a client socket '" + << strerror(errno) << "' " << endl; + mFinished = true; + break; + } + } while (!mNetMessage->Extract(netbuf, servermsg)); + + if (!servermsg.empty()) + { + mNetMessage->PrepareToSend(servermsg); + mAgentSocket->send(servermsg.data(), servermsg.size(), + MSG_DONTWAIT, Socket::DONT_CHECK); + + cycleFinishTime = boost::get_system_time() + + boost::posix_time::milliseconds(mCycleMillisecs); + } + } + catch (boost::thread_interrupted e) + { + } + } + mServerSocket->close(); + mFinished = true; + mAgentConnectionThread.join(); +} + +void AgentProxy::AgentConnectionHandler() +{ + TRawBuffer recvbuf; + + while (!mFinished) + { + int retval = mAgentSocket->recv(mCycleMillisecs * 4, + recvbuf.data(), recvbuf.size()); + if (retval > 0) + { + boost::mutex::scoped_lock agentBufLock(mAgentBufferMutex); + mAgentBuffer->AddFragment(string(recvbuf.data(), recvbuf.size())); + } + else if (retval <= 0 && errno != EAGAIN) + { + GetLog()->Error() << "(AgentProxy) ERROR: '" << GetName() + << "' recv returned error on a client socket '" + << strerror(errno) << "' " << endl; + mFinished = true; + } + } +} Property changes on: trunk/spark/lib/oxygen/proxyserver/agentproxy.cpp ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: trunk/spark/lib/oxygen/proxyserver/agentproxy.h =================================================================== --- trunk/spark/lib/oxygen/proxyserver/agentproxy.h (rev 0) +++ trunk/spark/lib/oxygen/proxyserver/agentproxy.h 2010-01-01 22:01:05 UTC (rev 132) @@ -0,0 +1,85 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Thu Dec 31 2009 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2004-2009 RoboCup Soccer Server 3D Maintenance Group + $Id$ + + 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; version 2 of the License. + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#ifndef OXYGEN_AGENTPROXY_H +#define OXYGEN_AGENTPROXY_H + +#include <boost/array.hpp> +#include <boost/thread/thread.hpp> +#include <boost/thread/mutex.hpp> +#include <oxygen/oxygen_defines.h> +#include <zeitgeist/class.h> +#include <zeitgeist/node.h> +#include <rcssnet/addr.hpp> +#include <rcssnet/socket.hpp> +#include <oxygen/simulationserver/netbuffer.h> +#include <oxygen/simulationserver/netmessage.h> + +namespace oxygen +{ + +/** \class AgentProxy TODO: add description + */ +class OXYGEN_API AgentProxy: public zeitgeist::Node +{ +private: + typedef boost::array<char, 32 * 1024> TRawBuffer; + +public: + AgentProxy(int cycleMillisecs = 0); + virtual ~AgentProxy(); + + /** starts the proxy for a single agent */ + void Start(boost::shared_ptr<rcss::net::Socket> agentSocket, + rcss::net::Addr serverAddress); + + /** does the agent connection terminated so not */ + bool IsFinished() { return mFinished; } + + /** stops the current running proxy (if running!) */ + void Stop(); + +private: + /** manages server connection */ + void ServerConnectionHandler(); + + /** manages agent connection */ + void AgentConnectionHandler(); + +private: + const int mCycleMillisecs; + + /** shows if the proxy execution is finished */ + bool mFinished; + boost::shared_ptr<NetMessage> mNetMessage; + boost::shared_ptr<rcss::net::Socket> mServerSocket; + boost::shared_ptr<rcss::net::Socket> mAgentSocket; + boost::shared_ptr<NetBuffer> mAgentBuffer; + boost::thread mServerConnectionThread; + boost::thread mAgentConnectionThread; + boost::mutex mAgentBufferMutex; +}; + +DECLARE_CLASS(AgentProxy); + +} // namespace oxygen + +#endif // OXYGEN_AGENTPROXY_H Property changes on: trunk/spark/lib/oxygen/proxyserver/agentproxy.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: trunk/spark/lib/oxygen/proxyserver/agentproxy_c.cpp =================================================================== --- trunk/spark/lib/oxygen/proxyserver/agentproxy_c.cpp (rev 0) +++ trunk/spark/lib/oxygen/proxyserver/agentproxy_c.cpp 2010-01-01 22:01:05 UTC (rev 132) @@ -0,0 +1,30 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Thu Dec 31 2009 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2004-2009 RoboCup Soccer Server 3D Maintenance Group + $Id$ + + 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; version 2 of the License. + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#include "agentproxy.h" + +using namespace oxygen; +using namespace std; + +void CLASS(AgentProxy)::DefineClass() +{ + DEFINE_BASECLASS(zeitgeist/Node); +} Property changes on: trunk/spark/lib/oxygen/proxyserver/agentproxy_c.cpp ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: trunk/spark/lib/oxygen/proxyserver/proxyserver.cpp =================================================================== --- trunk/spark/lib/oxygen/proxyserver/proxyserver.cpp (rev 0) +++ trunk/spark/lib/oxygen/proxyserver/proxyserver.cpp 2010-01-01 22:01:05 UTC (rev 132) @@ -0,0 +1,146 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Thu Dec 31 2009 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2004-2009 RoboCup Soccer Server 3D Maintenance Group + $Id$ + + 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; version 2 of the License. + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#include "proxyserver.h" +#include <zeitgeist/logserver/logserver.h> +#include <oxygen/simulationserver/netcontrol.h> +#include <rcssnet/exception.hpp> +#include "agentproxy.h" + +using namespace oxygen; +using namespace zeitgeist; +using namespace std; +using namespace rcss::net; + +ProxyServer::ProxyServer() : Leaf(), + mRunning(false), + mCycleMillisecs(0), + mLocalAddr(0, Addr::ANY), + mServerAddr(0, Addr::ANY), + mSocket(NetControl::CreateSocket(NetControl::ST_TCP)) +{ +} + +ProxyServer::~ProxyServer() +{ +} + +void ProxyServer::SetProxyPort(Addr::PortType port) +{ + mLocalAddr.setPort(port); +} + +Addr::PortType ProxyServer::GetProxyPort() const +{ + return mLocalAddr.getPort(); +} + +void ProxyServer::SetServerAddress(const rcss::net::Addr &serverAddress) +{ + mServerAddr = serverAddress; +} + +void ProxyServer::SetCycleLength(int millisecs) +{ + mCycleMillisecs = millisecs; +} + +bool ProxyServer::Run() +{ + bool success = false; + + if (mLocalAddr.getPort() == 0) + { + GetLog()->Error() + << "(ProxyServer) ERROR: local port has no been set in '" + << GetClass()->GetName() << "'\n"; + return false; + } + if (mServerAddr.getPort() == 0) + { + GetLog()->Error() + << "(ProxyServer) ERROR: server address has no been set in '" + << GetClass()->GetName() << "'\n"; + return false; + } + if (!mSocket) + { + GetLog()->Error() + << "(ProxyServer) ERROR: No valid socket has been created.\n"; + return false; + } + if (mCycleMillisecs == 0) + { + GetLog()->Error() + << "(ProxyServer) ERROR: Cycle length not set.\n"; + return false; + } + + int ret = mSocket->setReuseAddr(true); + if (ret < 0) + { + GetLog()->Warning() + << "(ProxyServer) failed to enable reuse of server socket " + << "with '" << strerror(errno) << "'\n"; + } + + try + { + mSocket->bind(mLocalAddr); + mSocket->listen(50); + mRunning = true; + + do + { + Addr addr; + boost::shared_ptr<Socket> socket(mSocket->accept(addr)); + if (socket) + { + GetLog()->Normal() << "(ProxyServer) accepted a new connection" + << " from " << socket->getPeer() << '\n'; + + AgentProxy *agentProxy = new AgentProxy(mCycleMillisecs); + agentProxy->Start(socket, mServerAddr); + mClientProxyList.push_back(agentProxy); + } + } while (mRunning); + success = true; + } + catch (BindErr error) + { + GetLog()->Error() << "(ProxyServer) failed to bind socket with '" + << error.what() << "'" << endl; + } + catch (ListenErr error) + { + GetLog()->Error() << "(ProxyServer) failed to listen on socket with '" + << error.what() << "'" << endl; + } + catch (AcceptErr error) + { + GetLog()->Error() << "(ProxyServer) '" << GetName() + << "' failed to accept TCP connection with '" << error.what() + << endl; + } + + mSocket->close(); + return success; +} Property changes on: trunk/spark/lib/oxygen/proxyserver/proxyserver.cpp ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: trunk/spark/lib/oxygen/proxyserver/proxyserver.h =================================================================== --- trunk/spark/lib/oxygen/proxyserver/proxyserver.h (rev 0) +++ trunk/spark/lib/oxygen/proxyserver/proxyserver.h 2010-01-01 22:01:05 UTC (rev 132) @@ -0,0 +1,81 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Thu Dec 31 2009 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2004-2009 RoboCup Soccer Server 3D Maintenance Group + $Id$ + + 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; version 2 of the License. + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#ifndef OXYGEN_PROXYSERVER_H +#define OXYGEN_PROXYSERVER_H + +#include <boost/ptr_container/ptr_list.hpp> +#include <oxygen/oxygen_defines.h> +#include <zeitgeist/class.h> +#include <zeitgeist/leaf.h> +#include <rcssnet/addr.hpp> +#include <rcssnet/socket.hpp> + +namespace oxygen +{ + +class AgentProxy; + +/** \class ProxyServer TODO: Add description + */ +class OXYGEN_API ProxyServer: public zeitgeist::Leaf +{ +public: + ProxyServer(); + virtual ~ProxyServer(); + + /** sets the local port, on which connections are accepted */ + void SetProxyPort(rcss::net::Addr::PortType port); + + /** returns the local port, on which connections are accepted */ + rcss::net::Addr::PortType GetProxyPort() const; + + /** sets the server address to connect to */ + void SetServerAddress(const rcss::net::Addr &serverAddress); + + /** sets the length of a cycle in milli seconds */ + void SetCycleLength(int millisecs); + + /** starts the run loop of the proxy server, wait for incomming connection + * requests */ + bool Run(); + +private: + bool mRunning; + int mCycleMillisecs; + + /** the local port, on which connections are accepted */ + rcss::net::Addr mLocalAddr; + + /** the server address to which we should connect */ + rcss::net::Addr mServerAddr; + + /** the socket used to accept connections */ + boost::shared_ptr<rcss::net::Socket> mSocket; + + boost::ptr_list<AgentProxy> mClientProxyList; +}; + +DECLARE_CLASS(ProxyServer); + +} // namespace oxygen + +#endif // OXYGEN_PROXYSERVER_H Property changes on: trunk/spark/lib/oxygen/proxyserver/proxyserver.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: trunk/spark/lib/oxygen/proxyserver/proxyserver_c.cpp =================================================================== --- trunk/spark/lib/oxygen/proxyserver/proxyserver_c.cpp (rev 0) +++ trunk/spark/lib/oxygen/proxyserver/proxyserver_c.cpp 2010-01-01 22:01:05 UTC (rev 132) @@ -0,0 +1,47 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Thu Dec 31 2009 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2004-2009 RoboCup Soccer Server 3D Maintenance Group + $Id$ + + 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; version 2 of the License. + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#include "proxyserver.h" + +using namespace oxygen; +using namespace std; + +FUNCTION(ProxyServer, setCycleLength) +{ + unsigned int inMillisecs; + + if ( + (in.GetSize() != 1) || + (! in.GetValue(in.begin(), inMillisecs)) + ) + { + return false; + } + + obj->SetCycleLength(inMillisecs); + return true; +} + +void CLASS(ProxyServer)::DefineClass() +{ + DEFINE_BASECLASS(zeitgeist/Leaf); + DEFINE_FUNCTION(setCycleLength); +} Property changes on: trunk/spark/lib/oxygen/proxyserver/proxyserver_c.cpp ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Modified: trunk/spark/lib/oxygen/simulationserver/netmessage.cpp =================================================================== --- trunk/spark/lib/oxygen/simulationserver/netmessage.cpp 2009-12-29 19:52:44 UTC (rev 131) +++ trunk/spark/lib/oxygen/simulationserver/netmessage.cpp 2010-01-01 22:01:05 UTC (rev 132) @@ -19,6 +19,7 @@ */ #include "netmessage.h" #include "netbuffer.h" +#include <boost/cstdint.hpp> #include <rcssnet/socket.hpp> #ifndef WIN32 @@ -44,8 +45,8 @@ void NetMessage::PrepareToSend(std::string& msg) { // prefix the message with it's payload length - unsigned int len = htonl(static_cast<u_long>(msg.size())); - string prefix((const char*)&len,sizeof(unsigned int)); + boost::uint32_t len = htonl(static_cast<u_long>(msg.size())); + string prefix((const char*) &len, sizeof(len)); msg = prefix + msg; } @@ -57,7 +58,7 @@ } // a message is prefixed with it's payload length - const unsigned int preSz = sizeof(unsigned int); + const unsigned int preSz = sizeof(boost::uint32_t); string& data = buffer->GetData(); @@ -66,7 +67,8 @@ return false; } - unsigned int msgLen = ntohl((*(unsigned int*)data.data())); + unsigned int msgLen = + ntohl((*reinterpret_cast<const boost::uint32_t*>(data.data()))); if (data.size() < (msgLen + preSz)) { Modified: trunk/spark/lib/oxygen/simulationserver/simcontrolnode.h =================================================================== --- trunk/spark/lib/oxygen/simulationserver/simcontrolnode.h 2009-12-29 19:52:44 UTC (rev 131) +++ trunk/spark/lib/oxygen/simulationserver/simcontrolnode.h 2010-01-01 22:01:05 UTC (rev 132) @@ -84,8 +84,6 @@ float mTime; float mStep; - - boost::condition mCond; }; DECLARE_CLASS(SimControlNode); Modified: trunk/spark/lib/zeitgeist/fileserver/fileserver.cpp =================================================================== --- trunk/spark/lib/zeitgeist/fileserver/fileserver.cpp 2009-12-29 19:52:44 UTC (rev 131) +++ trunk/spark/lib/zeitgeist/fileserver/fileserver.cpp 2010-01-01 22:01:05 UTC (rev 132) @@ -31,7 +31,6 @@ FileServer::FileServer() : Node(), mNextHandle(1) { - mResourceLocations.push_back(salt::RFile::BundlePath()); } FileServer::~FileServer() Modified: trunk/spark/lib/zeitgeist/zeitgeist.cpp =================================================================== --- trunk/spark/lib/zeitgeist/zeitgeist.cpp 2009-12-29 19:52:44 UTC (rev 131) +++ trunk/spark/lib/zeitgeist/zeitgeist.cpp 2010-01-01 22:01:05 UTC (rev 132) @@ -21,6 +21,8 @@ #include "zeitgeist.h" #include <iostream> #include <sstream> +#include <salt/fileclasses.h> +#include "fileserver/fileserver.h" using namespace std; using namespace zeitgeist; @@ -73,6 +75,7 @@ // setup the dot directory in the script server mCore->GetScriptServer()->SetDotName(dotName); mCore->GetScriptServer()->SetupDotDir(); + mCore->GetFileServer()->AddResourceLocation(salt::RFile::BundlePath()); // run the zeitgeist init script mCore->GetScriptServer()->RunInitScript This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |