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

Author Topic: Packet::Append  (Read 3109 times)

0 Members and 1 Guest are viewing this topic.

troopson

  • Newbie
  • *
  • Posts: 30
    • View Profile
Packet::Append
« on: July 21, 2011, 06:22:46 pm »
I got a packet like this:
[sf::Uint8][sf::Uint32][std::string][rest..]
now i want to make a new packet which has only sf::Uint8 and rest. How do i do that using append?(the problem is std::string..)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Packet::Append
« Reply #1 on: July 21, 2011, 06:28:43 pm »
sf::Packet is made for packing data and sending it. You're not supposed to do anything else with it, you should construct it right before sending to the socket with the final data.

What do you need to do that?
Laurent Gomila - SFML developer

troopson

  • Newbie
  • *
  • Posts: 30
    • View Profile
Packet::Append
« Reply #2 on: July 21, 2011, 06:34:56 pm »
I get packet from client [sf::Uint8 type ][sf::Uint32 id ][std::string lobbyname ][rest]

i want to send from server packet without id and lobbyname, only packet type and the rest.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Packet::Append
« Reply #3 on: July 21, 2011, 06:39:06 pm »
Construct a new packet with only type and rest, and ignore id and lobbyname?

The overloaded operators << and >> will help you at this task.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

troopson

  • Newbie
  • *
  • Posts: 30
    • View Profile
Packet::Append
« Reply #4 on: July 21, 2011, 06:42:24 pm »
yeah dude but all data is IN the packet. to get the rest i need the starting pointer of rest. To do that i need to know what is the size of [sf::Uint8 type ][sf::Uint32 id ][std::string lobbyname ]

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Packet::Append
« Reply #5 on: July 21, 2011, 06:46:23 pm »
Extract everything, and send only the variables that you want.
Laurent Gomila - SFML developer

 

anything