Restructered project and better building
This commit is contained in:
40
testClient/src/ClientStates.cpp
Normal file
40
testClient/src/ClientStates.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "ClientStates.h"
|
||||
|
||||
#include "Protocoll.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void Connecting::update(unsigned int delta)
|
||||
{
|
||||
std::cout << "Connecting.. (Sending Request)" << std::endl;
|
||||
m_client->sendConnectionRequest(m_client->serverIP);
|
||||
if (SDLNet_UDP_Recv(m_client->udpSocket, m_client->receivedPacket))
|
||||
{
|
||||
std::cout << "Something received.." << std::endl;
|
||||
switch (*(m_client->receivedPacket->data))
|
||||
{
|
||||
case CONNECTION_ACCEPTED:
|
||||
{
|
||||
int index = ((ConnectionAccepted *)(m_client->receivedPacket->data))->index;
|
||||
std::cout << "Server accepted Connection! My Index ist: " << index << std::endl;
|
||||
m_client->setClientState(m_client->connected);
|
||||
}
|
||||
break;
|
||||
case CONNECTION_DENIED:
|
||||
std::cout << "Server denied Connection!" << std::endl;
|
||||
m_client->setClientState(m_client->disconnected);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Connected::update(unsigned int delta)
|
||||
{
|
||||
std::cout << "I AM IN CONNECTED STATE!" << std::endl;
|
||||
}
|
||||
|
||||
void Disconnected::update(unsigned int delta)
|
||||
{
|
||||
std::cout << "I AM IN DISCONNECTED STATE!" << std::endl;
|
||||
}
|
||||
Reference in New Issue
Block a user