-
Notifications
You must be signed in to change notification settings - Fork 500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose a way to know if data has been received by a peer #248
Comments
|
@RevenantX |
@Krakean еще руки не дошли. |
I posted this on discord a few days ago an never got a response from anyone so might as well post it here as well. Just had an idea that could be useful and i wanted to see if there is a way to do it or if maybe something could be added. Basically atm i'm running into some issues on highly latent connections with a lot of packet loss with some packets taking a long time to actually get received by the server(this particular case i'm having the client has very bad upload and decent download). Would there be any decent way to have a way from user code of the library to determine when a packet has been acknowledged by the server with reliable channel types? Rather than trying to send extra event ack packets from the server manually? This is basically the same thing as this feature request so i wanted to give my +1 |
If we go ahead, I would recommend something simple like a "ReliableAckCount" |
I don't think a |
It would not be, but it could Identify a problem. |
Personally, I wouldn't use a callback. I'd add a function that can be polled. |
So i think something like giving each message to be sent an increment value, that could be checked against the latest acknowledged packet's id. That way you know if your packet has been received with a reliable ordered delivery method. Or hell you don't even need to give each one a value explicitly, but like @Apostolique said you could have a per-channel count of the current # of ack'd "messages", and the total number of messages requested to be sent(didn't want to use the term "packet" here since a single message could be sent multiple times if it doesn't get ack'd), and then you could read the current requested to be sent value before sending your message need then check the ack'd count to verify with it was received. This would probably be simpler to implement. |
And i did get a short response about this from him on discord, i said i am considering trying to implement this myself if it doesn't happen shortly and he responded saying:
Still considering doing an implementation myself and making a pull request though. |
Done. Usage example: EventBasedNetListener listener = new EventBasedNetListener();
NetManager client = new NetManager(listener);
client.Start();
client.Connect("localhost" /* host ip or name */, 9050 /* port */, "SomeConnectionKey" /* text key or NetDataWriter */);
listener.DeliveryEvent += (peer, obj) =>
{
Console.WriteLine("Message delivered: " + (string)obj);
};
listener.PeerConnectedEvent += peer =>
{
peer.SendWithDeliveryEvent(NetDataWriter.FromString("Hello server!"), 0, DeliveryMethod.ReliableOrdered, "USER_DATA");
};
//also you can tune NetManager.UnsyncedDeliveryEvent
//If true - delivery event will be called from "receive" thread otherwise on PollEvents call If you use your INetEventListener implementation - just implement IDeliveryEventListener and it will work |
…evenantX#248", optimize some things.
After calling Send on a NetPeer, it would be nice to expose a way to know if the data has been received. Especially for reliable messages.
Edit: Might even be nice to also have this for Connect.
The text was updated successfully, but these errors were encountered: