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

Author Topic: const qualifier in send() function  (Read 2002 times)

0 Members and 1 Guest are viewing this topic.

fr1ar

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
const qualifier in send() function
« on: May 14, 2014, 10:32:07 am »
Is it possible to make first argument type const Packet& in future releases?
It doesn't look like it can be modified.

Socket::Status UdpSocket::send(Packet& packet, const IpAddress& remoteAddress, unsigned short remotePort)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: const qualifier in send() function
« Reply #1 on: May 14, 2014, 10:34:35 am »
It can, because of onSend() and onReceive().

But I agree that this is not a very beautiful limitation, especially since these methods are not used in the very most cases. Maybe in the future we can find a design that works without inheritance.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

fr1ar

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: const qualifier in send() function
« Reply #2 on: May 14, 2014, 10:51:49 am »
Ok, it's not a big problem, my workaround works fine :)

void MySocket::send(const Address& address, const sf::Packet& packet)
{
        _socket.send(packet.getData(), packet.getDataSize(), address._ip, address._port);
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: const qualifier in send() function
« Reply #3 on: May 14, 2014, 11:01:52 am »
This is not how a packet is sent internally. You may end up with problems if you use this code.
Laurent Gomila - SFML developer

 

anything