Added the beginnings of Boost.Function and Boost.Threads for callback handling and threaded network handling

git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@6 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
John Hurliman
2006-05-18 14:18:13 +00:00
parent 9602c23c05
commit 026ebea111
13 changed files with 303 additions and 141 deletions

View File

@@ -1,16 +1,52 @@
#include "SecondLife.h"
SecondLife::SecondLife()
SecondLife::SecondLife()
{
boost::thread _placeHolder;
_protocol = new ProtocolManager();
_network = new Network(_protocol);
_decoder = new Decoder();
}
SecondLife::~SecondLife()
{
_decoder = new Decoder();
_running = true;
}
SecondLife::~SecondLife()
{
delete _protocol;
delete _network;
delete _decoder;
delete _decoder;
}
void SecondLife::connectSim(boost::asio::ipv4::address ip, unsigned short port, U32 code, bool setCurrent)
{
if (!_network) {
//FIXME: Log
return;
}
boost::thread thread;
//FIXME: Run the below function in the above thread
_network->connectSim(ip, port, code, setCurrent);
}
void SecondLife::tick()
{
Packet* packet;
// When we get to stream handling, this function will build data stream
// classes and append new data, for sounds/images/animations/etc
// tick() will process all of the outstanding packets, building classes and
// firing callbacks as it goes
if (_network) {
while (_network->inbox().size() > 0) {
packet = _network->inbox().front();
_network->inbox().pop_front();
std::string command = packet->command();
callback handler = _callbacks[command];
bool returnValue = handler(command, packet);
if (returnValue) {
;
}
}
}
}