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.


Messages - Honorabl3

Pages: [1]
1
Network / Re: Converting packet to bytes and back?
« on: November 04, 2014, 10:09:50 pm »
Stop using full quotes!!! Only quote relevant bits or don't quote at all if the context is obvious!!! >:(
Haha I was going to remove some of the quotes, but I had food cooking in the kitchen. I was thinking "No one will complain about it this last time."

2
Network / Re: Converting packet to bytes and back?
« on: November 04, 2014, 09:36:10 pm »
Quote from: Ixrec
UDP and TCP do not function similarly at all, even if most networking libraries give similar APIs for them.  You might want to read a bit more about what they actually are.

My bad!!! I mean't enet! Let me post the fixed version below.
Quote
My bad, I don't need TCP. I'm using enet because it functions like a TCP connection. It is faster then a TCP connection, and saves a client or w/e onto a .peer class object so that when a UDP connection is received it keeps the connection running.

But that aside, his original question was why are you trying to use both SFML and ENet for your networking?  Specifically, what feature is SFML lacking that ENet has?  SFML supports UDP too.
I'm using SFML's sf::Packet class because it's very easy to load and unload variables. enet would never send a sf::Packet, it would only send some binary data (which was created from the sf::Packet). Enet allows a client session instead of one simple UDP packet.

3
Network / Re: Converting packet to bytes and back?
« on: November 04, 2014, 07:50:52 pm »
I'm using the enet network library to make my game utilize both TCP and UDP.
The site explicitly states that Enet is a UDP networking library. For TCP you will have to use something else.

Is there a reason why you don't use SFML, do you need certain features?
My bad, I don't need TCP. I'm using UDP because it functions like a TCP connection. It is faster then a TCP connection, and saves a client or w/e onto a .peer class object so that when a UDP connection is received it keeps the connection running.

Apparently you need to re-read my post. That's exactly what I wrote.
Your post doesn't mention converting binary data to sf::Packet?

4
Network / Re: Converting packet to bytes and back?
« on: November 04, 2014, 06:18:42 pm »
I think you understand what I'm trying to do better than anyone here. I am trying to convert the sf::Packet into binary data and send that over enet. But I want to just know how to convert binary data back into an sf::Packet.

Thanks for posting, I almost gave up on this idea.

5
Network / Re: Converting packet to bytes and back?
« on: October 31, 2014, 10:09:24 pm »
Thank you for your help, I will be using std::stringstream I guess.

6
Network / Re: Converting packet to bytes and back?
« on: October 31, 2014, 09:06:31 pm »
Don't send/receive sf::Packet with ENet. sf::Packet has its own internal protocol, which works well with SFML sockets, but won't be understood by other libraries.
I really hope you're misunderstanding how I'm doing this. I really REALLY want to use sf::Packet to send stuff  because it's easy to pack and unload variables. I plan on converting the packet into raw bytes so that sending the raw data won't interfere with anything. Can I do it this way? If not, how do you recommend I send data? If I send it as a string, I don't want to bother converting a string to an integer for position stuff.

7
Network / Converting packet to bytes and back?
« on: October 31, 2014, 06:33:23 am »
I heard that sending packets in bytes is faster. So as my title ask, how do you convert a packet to bytes and back? I'm using the enet network library to make my game utilize both TCP and UDP. I plan on packing everything I need into a sf::Packet and converting that into bytes then sending that.

Code: [Select]
// Server
sf::Packet packet = bleh;
bleh << variables;
bleh << positions; // Loading the packet up with stuff..
ENetPacket * packet = enet_packet_create (bleh.getData(), bleh.getDataSize() + 1, ENET_PACKET_FLAG_RELIABLE);
enet_peer_send (peer, 0, packet);

// Client
sf::Packet packet;
packet.append(event.packet->data, event.packet->dataLength);

Is that at all near close? If you're confused about the context of the variables, check the enet library I linked to above. I've also provided a UNFINISHED server-sided spoiler of some code if it helps:

(click to show/hide)

8
General / Re: sf::Thread being used in class functions. [SFML 2.1]
« on: September 30, 2013, 09:38:32 pm »
Well, that seems to be the answer to my three day problem I've been having. Once I get home I'll test it.

9
General / sf::Thread being used in class functions. [SFML 2.1]
« on: September 30, 2013, 07:17:51 pm »
I'm on my phone to type this, but I wanted to see if there was a solution to my problem. I won't be going into too much depth unless really absoluty needed. Anyway I'll hop into the issue.

It seems when I tell a thread to run from a class method, it won't work.
Code: [Select]
void player::blah()
{
     sf::Thread thread(&rawr, sf::Vector2f(6, 5));
     thread.launch();
}

void player::rawr(sf::Vector2f dir)
{
      //rawr stuff
}

P.S. I have read the thread documentation. It hasn't helped.

Pages: [1]