Open SaySayTakamura opened 1 year ago
Hi there! Thanks for the suggestion. To clarify, you're mainly asking for a way to see if the "send queue" for your client is actually empty or not? This would be a very easy thing to add.
Hi there! Thanks for the suggestion. To clarify, you're mainly asking for a way to see if the "send queue" for your client is actually empty or not? This would be a very easy thing to add.
Oh yeah, exactly what i had in mind, i remember seeing the packet_queue
member on the client struct.
But i didn't know if what i have in mind is going to work:
//Returns true if there's anything pending, false when there's nothing yet to be sent
bool cn_client_packet_pending(client)
{
cn_client_t c = client;
return ((c.p_client.packet_queue.size_left == c.p_client.packet_queue.capacity-1) ? true : false)
}
In fact imma give it a try once i get home.
Also: my deepest apologies for the bothering and the delayed response (went to sleep after creating the issue)
Update: went to check the buffer size with Capacity
and Size_Left
members of the circular_buffer
they don't change (this also goes for sizeof(), which was my first idea)
Output:
//First call
Buffer Size - 1048576, Size Left - 1048576, Sizeof - 32
Client sends message (c.Send())
//Second call
Buffer Size - 1048576, Size Left - 1048576, Sizeof - 32
Disconnect (c.Shutdown())
Application Close(done = true)
Not exactly what i had in mind but it does the job:
if (c.IsConnected)
{
std::string dt = "Hello There";
static float i = 0;
i += ElapsedTime(); //Directly calls ct_time()
if(i > 0.5) //Default : 2
{
printf("Sending");
c.send(dt);
i = 0;
done = true; // Closes the application.
}
}
This code works but with certain delay between sends, so i need to adjust this for this to perform better.
Note: it's worth to mention that i took this snippet from the example, just out of nowhere haha.
Hello there, my deepest apologies for the bothering, but i came to ask something and maybe suggest something.
I am quite new to this network thing, my apologies if i say or do something wrong.
I walked through the examples and after a while messing with them i went to create a class for both Server and Client and implement on my Debugger project.
Everything was fine until i went to test the client class. It works, but there's something wrong.
Look at this:
Ok, the concept for this code is, Create a client, connects to the localhost, sends an string to the server, then disconnect and then end the program.
Now let's go to the server output:
Where is the message is the client send?
Problem is, i call to
c.Shutdown()
anddone = true
right after "sending" the message, which cancels the next call ofc.Process()
and with that the message i just sent didn't get processed.Took me a while to find this out (yup, dumb me), but still something like:
bool cn_client_packet_pending(client)
orbool cn_client_packet_send(client)
would be very useful.Example:
The second one would be quite harder to implement, since it would need a server response i suppose, but the first one i think it would be easier to do, i would implement it myself but i don't know how this would work and the nuances behind it.
Well, i think this is it, my deep apologies for the bothering and thanks for reading.
Have a great night.