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

Add pong delegate support for websoket connection and resource #2156

Merged
merged 1 commit into from
Nov 26, 2020

Conversation

avr39-ripe
Copy link
Contributor

Add ability to call delegate on pong frame reception. This is useful for
closing stalled connections. Websocket server can send ping frames periodically and check for pong back from clients. On pong reception server can reset some counters attached to websocket connection via setUserData. Also server periodically checks for counter not reaching some minimum value for every connection and close connections that do not reply to ping request assuming them as stalled. Connection may stall if some hard network problem occurs and there is no proper way to close client connection nor by websocket protocol or tcp.
Remove websocket state change before calling close() in
WebsocketConnection destructor. Without this change if connection was
removed by WebsocketRecource, onDisconnect delegate for Websocket
connection will not run.

Add ability to call delegate on pong frame reception. This is useful for
closing stalled connections.
Remove websocket state change before calling close() in
WebsocketConnection destructor. Without this change if connection was
removed by WebsocketRecource, onDisconnect delegate for Websocket
connection will not run.
@@ -73,7 +73,6 @@ class WebsocketConnection

virtual ~WebsocketConnection()
{
state = eWSCS_Closed;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason to remove the change of state here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if close method got connection in eWSCS_Closed state it do not fire onDisconnect delegate and this is not good. close() method change state by itself, and as far as I understand changing state to eWSCS_Closed in close() method do not hurt anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

void WebsocketConnection::close()
Here is it, on line 269 there is delegate call, but it inside if(state != eWSCS_Closed) ...

@slaff slaff added this to the 4.2.0 milestone Nov 25, 2020
@slaff slaff removed the 3 - Review label Nov 26, 2020
@slaff slaff merged commit 7b6a003 into SmingHub:develop Nov 26, 2020
@avr39-ripe avr39-ripe deleted the feature/pongDelegate branch November 26, 2020 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants