Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - r4gTime

Pages: [1]
1
Network / Packets : Vector Transfers and sf::objects
« on: April 29, 2020, 03:54:26 pm »
Hello,

I feel like I'm  kind alone on this forum but I still try :)

I have two question :

1- Is it possible to send a structure (or whatever) with vectors in it by packet >> ?
Like this :
typedef struct BMMaps BMMap;
        struct BMMaps
        {
            std::string nom = "Map par défaut" ;
            int background = 0;
            std::vector<Plateforme> plateformes;

        };
inline sf::Packet& operator <<(sf::Packet& packet, const BMMap& m)
{
    return packet << m.nom << m.background << m.plateformes ;
}
inline sf::Packet& operator >>(sf::Packet& packet, BMMap& m)
{
    return packet >> m.nom >> m.background >> m.plateformes ;
}
 

This doesn't work of course, and when I try to send the size of the vector then every element in it with a for(i=0; i < myVector.size() ; i++) , it gives me an error as well .

2- Is it possible to send sf::objects in packet ?
I'd like to send a lot of sf::RectangleShape , or CircleShape, but this :
sf::RectangleShape r;
sf::Packet p << r;
 
doesn't work. I mean, I guess sfml made its own packet object compatible with its own others objetcs ?


Thanks for your help,

Cya

2
Network / Non-blocking UDP socket doesn't receive any data
« on: April 20, 2020, 09:33:27 am »
Hi, I'm wondering why when I put my socket in non-blocking I don't receive anything ?

When I send data to this socket, the following code works :
broadcastSocket.setBlocking(true);
            broadcastSocket.bind(52001);
            if(broadcastSocket.receive(udpp,ip,port) == sf::Socket::Done)
            cout << "Data received" << endl;

but this one doesn't :
broadcastSocket.setBlocking(false);
            broadcastSocket.bind(52001);
while(1)
{
            if(broadcastSocket.receive(udpp,ip,port) == sf::Socket::Done)
            cout << "Data received" << endl;
}

Thanks for your help !

Pages: [1]