acmacalister / jetfire

WebSocket (RFC 6455) client library for iOS & OS X
Apache License 2.0
518 stars 83 forks source link

Timeout from ping #84

Open nathanday opened 6 years ago

nathanday commented 6 years ago

We want to have a time out feature when we haven't received anything from the server including pongs from our pings, but I don't see how we can know when we get a pong response from our ping. What am I missing, whats the point of us sending a ping if we can not handle the corresponding return pongs, the server sends its own pings to test if we still available? It we be nice if we knew when the server sent us a ping as well as that tells us it still there as well.

mistal-distal commented 5 years ago

Ping/Pong delegate method unfortunately weren't implemented in this library.

So this lib does do ping/pong but it's at a lower level in the ProcessRawMessage function, meaning it's unusable from an application logic perspective.

Quick way around this is to come up with a language between the server and client, for example send three raw bytes /00/01/00, then catch this in the didReceiveData delegate and deal with it manually.

I understand this isn't optimal because you'd like to use the websocket ping/pong functionality but its a quick fix.

You could also modify the library to catch the ping/pongs and pass them up the queue.