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

Author Topic: Question about using packets without sfml network.  (Read 2134 times)

0 Members and 1 Guest are viewing this topic.

flyffwaste

  • Newbie
  • *
  • Posts: 6
    • View Profile
Question about using packets without sfml network.
« on: May 02, 2014, 01:32:01 am »
Hello, I am currently charged with making an update to an existing server program, and I wanted to use sf::Packets to handle some of the data.  Currently the application receives data in a char array, all I wanted to know was how to change a char array so that it fits with a sf::Packet so that I can use rPacket >> data >> data2 etc.

I was able to already modify the server to send the packets with packet.getdata() / packet.getdatasize(), it is just casting the existing received packet into a sf::packet.

Thanks.
« Last Edit: May 02, 2014, 01:44:02 am by flyffwaste »

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Question about using packets without sfml network.
« Reply #1 on: May 02, 2014, 08:11:03 am »
You can easily convert between char arrays and std::string, so just use strings in your packet.

flyffwaste

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Question about using packets without sfml network.
« Reply #2 on: May 02, 2014, 06:06:16 pm »
You can easily convert between char arrays and std::string, so just use strings in your packet.

Thank you, but simply using strings is not an option.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Question about using packets without sfml network.
« Reply #3 on: May 02, 2014, 06:55:28 pm »
What about sf::Packet::append() and getData()/getDataSize()?

And instead of saying "it's not an option", it would be nice to know why.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

flyffwaste

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Question about using packets without sfml network.
« Reply #4 on: May 02, 2014, 11:25:46 pm »
What about sf::Packet::append() and getData()/getDataSize()?

And instead of saying "it's not an option", it would be nice to know why.

Thank you, I overlooked ::append it seems, it will for fill my needs exactly.