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:
@@ -1,18 +1,18 @@
|
||||
#include "Network.h"
|
||||
|
||||
Network::Network(ProtocolManager* protocol)
|
||||
{
|
||||
Network::Network(ProtocolManager* protocol)
|
||||
{
|
||||
_protocol = protocol;
|
||||
_currentSim = NULL;
|
||||
_avatar_id = 0;
|
||||
_session_id = 0;
|
||||
_secure_session_id = 0;
|
||||
}
|
||||
|
||||
Network::~Network()
|
||||
{
|
||||
_secure_session_id = 0;
|
||||
}
|
||||
|
||||
Network::~Network()
|
||||
{
|
||||
//FIXME: Close and free all the sockets
|
||||
// Delete all remaining packets
|
||||
// Delete all remaining packets
|
||||
}
|
||||
|
||||
void Network::receivePacket(const boost::asio::error& error, std::size_t length, char* receiveBuffer)
|
||||
@@ -26,7 +26,7 @@ void Network::receivePacket(const boost::asio::error& error, std::size_t length,
|
||||
|
||||
// Build a Packet object and fill it with the incoming data
|
||||
Packet* packet = new Packet();
|
||||
packet->setRawData((byte*)receiveBuffer, length);
|
||||
packet->rawData((byte*)receiveBuffer, length);
|
||||
|
||||
// Push it on to the list
|
||||
boost::mutex::scoped_lock lock(_inboxMutex);
|
||||
@@ -45,8 +45,7 @@ int Network::connectSim(boost::asio::ipv4::address ip, unsigned short port, U32
|
||||
}
|
||||
|
||||
// Build a connection packet
|
||||
Packet* packet = new Packet(_protocol, 36);
|
||||
packet->setCommand("UseCircuitCode");
|
||||
Packet* packet = new Packet("UseCircuitCode", _protocol, 36);
|
||||
packet->setField("CircuitCode", 1, "ID", &_session_id);
|
||||
packet->setField("CircuitCode", 1, "SessionID", &_session_id);
|
||||
packet->setField("CircuitCode", 1, "Code", &code);
|
||||
@@ -60,7 +59,7 @@ int Network::connectSim(boost::asio::ipv4::address ip, unsigned short port, U32
|
||||
|
||||
// Send the packet
|
||||
try {
|
||||
size_t bytesSent = socket->send_to(boost::asio::buffer(packet->getRawDataPtr(), packet->getLength()), 0, sim->endpoint());
|
||||
size_t bytesSent = socket->send_to(boost::asio::buffer(packet->rawData(), packet->length()), 0, sim->endpoint());
|
||||
// Debug
|
||||
printf("Sent %i byte connection packet\n", bytesSent);
|
||||
|
||||
@@ -110,7 +109,8 @@ int Network::sendPacket(boost::asio::ipv4::address ip, unsigned short port, Pack
|
||||
}
|
||||
|
||||
try {
|
||||
size_t bytesSent = _connections[i]->socket()->send_to(boost::asio::buffer(packet->getRawDataPtr(), packet->getLength()), 0, _connections[i]->endpoint());
|
||||
size_t bytesSent = _connections[i]->socket()->send_to(boost::asio::buffer(packet->rawData(), packet->length()),
|
||||
0, _connections[i]->endpoint());
|
||||
|
||||
// Debug
|
||||
printf("Sent %i bytes\n", bytesSent);
|
||||
|
||||
Reference in New Issue
Block a user