2013-06-16 19:54:02 -04:00
|
|
|
#include "client_network_manager.hpp"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
ClientNetworkManager::ClientNetworkManager()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ClientNetworkManager::~ClientNetworkManager()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClientNetworkManager::run()
|
|
|
|
{
|
|
|
|
if (enet_initialize() != 0)
|
|
|
|
{
|
|
|
|
printf("Could not initialize enet.\n");
|
|
|
|
return;
|
|
|
|
}
|
2013-06-17 14:06:02 -04:00
|
|
|
m_localhost = new STKHost();
|
|
|
|
m_localhost->setupClient(1, 2, 0, 0);
|
|
|
|
m_localhost->startListening();
|
2013-06-16 19:54:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClientNetworkManager::connect(uint32_t ip, uint16_t port)
|
|
|
|
{
|
|
|
|
STKPeer* peer = new STKPeer();
|
|
|
|
peer->connectToServer(m_localhost, ip, port, 2, 0);
|
|
|
|
|
|
|
|
m_peers.push_back(peer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClientNetworkManager::packetReceived(char* data)
|
|
|
|
{
|
|
|
|
printf("ClientNetworkManager::packetReceived()\n");
|
|
|
|
puts(data);
|
|
|
|
}
|
|
|
|
void ClientNetworkManager::sendPacket(char* data)
|
|
|
|
{
|
|
|
|
m_peers[0]->sendPacket(data);
|
|
|
|
}
|