Skip to content

Conversation

@sinha-abhishek
Copy link

A callback in case of pings not being received would help the client check whether connectivity is lost without sending a ping from the client periodically.

@sta
Copy link
Owner

sta commented Mar 12, 2015

Hello there,

I guess that the place at which the callback is emitted is not good. For example, does the following work? (ret is true?)

ws.OnPingRecieved += (sender, e) => { var ret = ws.Ping (); };
@sinha-abhishek
Copy link
Author

Hi,

I didn't really get what you meant there. Maybe the place is wrong, but I
did not get why do you need to check ws.Ping here.

Let me give a little context on why I added this change. So basically, I
have multiple client sockets connected to the server. The server sends ping
to all the clients every 10 seconds to check the latency. Now, for clients
to know if they have been disconnected I did not want to send a periodic
ping to server again, so I wanted to check how long since the last ping was
successfully received by the client.

For the same purpose my application needed a callback whenever client
receives a ping so I could track if connection is lost and try
re-connecting or closing.

So that is why the changes is needed. As to place, where I emitted, I chose
that because that is the place client sends the acknowledgement message for
the ping, so it seemed most appropriate to me. Let me know if you think any
other place is more suitable

On Thu, Mar 12, 2015 at 12:45 PM, sta notifications@github.com wrote:

Hello there,

I guess that the place at which the callback is emitted is not good. For
example, does the following work? (ret is true?)

ws.OnPingRecieved += (sender, e) => {
var ret = ws.Ping ();
};


Reply to this email directly or view it on GitHub
#113 (comment).

Thanks,
Abhishek

@sta
Copy link
Owner

sta commented Mar 13, 2015

I didn't really get what you meant there. Maybe the place is wrong, but I
did not get why do you need to check ws.Ping here.

Hey! This is an extreme example to raise up the problem easier. I guess this is an unexpected usage for you, but such usages are often raised.

The problem is the callback can block the message loop and jam some features that need that loop.

sta added a commit that referenced this pull request Jul 28, 2015
sta added a commit that referenced this pull request Jul 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants