Closed jrconlin closed 9 years ago
Also need to add tests, (once worker tests are built).
Thinking a bit more about this, I wonder if we could use a read deadline in the sniffer
loop to avoid the lock and extra goroutine:
sock.Socket.SetReadDeadline(time.Now().Add(self.pongInterval))
if err = websocket.Message.Receive(sock.Socket, &raw); err != nil {
if ne, ok := err.(net.Error); ok && ne.Timeout() {
if err = websocket.Message.Send(sock.Socket, "{}"); err == nil {
continue
}
}
self.stopped = true
// ...
}
If we don't hear from the client within the pong interval, Receive
will be unblocked with a timeout and we can send a ping packet. Otherwise, we'll reset the deadline on the next turn of the loop. What do you think?
This would be my preference, adding another goroutine per connection isn't free.
Agreed. On Dec 21, 2014 9:41 AM, "Ben Bangert" notifications@github.com wrote:
This would be my preference, adding another goroutine per connection isn't free.
— Reply to this email directly or view it on GitHub https://github.com/mozilla-services/pushgo/pull/175#issuecomment-67777862 .
r+; looks great! Thanks for cleaning up the AlwaysRoute
cruft, too.
Set up a routine to send out "{}" frames every period.
Potential TODOs:
Closes #174.