Files
libremetaverse/src/SecondLife.cpp

53 lines
1.1 KiB
C++
Raw Normal View History

#include "SecondLife.h"
SecondLife::SecondLife()
{
_protocol = new ProtocolManager();
_network = new Network(_protocol);
_decoder = new Decoder();
_running = true;
}
SecondLife::~SecondLife()
{
delete _protocol;
delete _network;
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) {
;
}
}
}
}