Skip to content
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

Closed
Apostolique opened this issue Oct 23, 2018 · 11 comments
Closed

Expose a way to know if data has been received by a peer #248

Apostolique opened this issue Oct 23, 2018 · 11 comments
Assignees

Comments

@Apostolique
Copy link

Apostolique commented Oct 23, 2018

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.

@ghost
Copy link

ghost commented Oct 23, 2018

  • for that one.

@Krakean
Copy link

Krakean commented Mar 11, 2019

@RevenantX
Здравствуй Руслан
Этот фич-реквест уже реализован, или ещё пока не дошли руки?

@RevenantX
Copy link
Owner

@Krakean еще руки не дошли.

@mdsitton
Copy link

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

@NVentimiglia
Copy link
Contributor

If we go ahead, I would recommend something simple like a "ReliableAckCount"

@Apostolique
Copy link
Author

I don't think a ReliableAckCount would be precise enough to identify specific messages.

@NVentimiglia
Copy link
Contributor

It would not be, but it could Identify a problem.
I suggested it in part out of fear of callbacks (and their garbage)

@Apostolique
Copy link
Author

Personally, I wouldn't use a callback. I'd add a function that can be polled.

@mdsitton
Copy link

mdsitton commented May 1, 2019

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.

@mdsitton
Copy link

mdsitton commented May 1, 2019

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:

RevenantX - this almost WIP
mdsitton - ah so you are working on it?
RevenantX - @mdsitton in some way

Still considering doing an implementation myself and making a pull request though.

@RevenantX RevenantX added this to the LiteNetLib 0.9 milestone May 1, 2019
RevenantX added a commit that referenced this issue Oct 23, 2019
@RevenantX
Copy link
Owner

RevenantX commented Oct 23, 2019

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
it will work for RelaibleOrdered and ReliableUnordered
and for fragmented messages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants