2006-05-17 13:48:37 +00:00
|
|
|
#include "SecondLife.h"
|
|
|
|
|
|
2006-05-18 14:18:13 +00:00
|
|
|
SecondLife::SecondLife()
|
2006-05-17 13:48:37 +00:00
|
|
|
{
|
|
|
|
|
_protocol = new ProtocolManager();
|
|
|
|
|
_network = new Network(_protocol);
|
2006-05-18 14:18:13 +00:00
|
|
|
_decoder = new Decoder();
|
|
|
|
|
_running = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SecondLife::~SecondLife()
|
|
|
|
|
{
|
2006-05-17 13:48:37 +00:00
|
|
|
delete _protocol;
|
|
|
|
|
delete _network;
|
2006-05-18 14:18:13 +00:00
|
|
|
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) {
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-05-17 13:48:37 +00:00
|
|
|
}
|