Hello. I was reading this (
http://www.sfml-dev.org/tutorials/2.1/network-packet.php) and am trying to extract data from my packet. However, for some reason, this error appears: "No operator "<<" matches these operands". Here is my file:
#include "ServerCore.hpp"
#include "Packet.hpp"
#include <SFML/Network/IpAddress.hpp>
#include <iostream>
ServerCore::ServerCore(int port)
: mSocket()
{
mPort = port;
}
void ServerCore::enterServerLoop()
{
if(mSocket.bind(mPort) != sf::Socket::Done)
{
std::cout << "SOEMTHING DIDNT WORK" << std::endl;
}
std::cout << "Initialized Server" << std::endl;
unsigned short port;
sf::IpAddress ip;
while(true)
{
std::cout << ":D" << std::endl;
sf::Packet packet;
std::size_t recieved;
if(mSocket.receive(packet, ip, port) != sf::Socket::Done)
{
}
ClientPacket::Type packetType;
if(packet >> packetType)
{
std::cout << "Player Quit!" << std::endl;
}
std::cout << "Recieved " << recieved << " bytes from " << mSender << " on port " << port << std::endl;
}
sf::Packet packet;
packet << ServerPacket::ServerStop;
if(mSocket.send(packet, mSender, port) != sf::Socket::Done)
{
std::cout << "I AM SAD" << std::endl;
}
}
and here is the affected line:
ClientPacket::Type packetType;
if(packet >> packetType)
{
std::cout << "Player Quit!" << std::endl;
}
Any ideas?