feat: the browser terminal on a WebSocket too, long polls when it does not connect or drops
This commit is contained in:
1 parent
73bb720ec6
commit
47f1b2e55b
4 files changed
+127
-12
No files matched your search
@@ -324,10 +324,18 @@ func (s *Session) Out() <-chan proto.OutMessage { return s.out }
|
||||
|
||||
// PollOut drains queued upstream messages, blocking up to timeout for the first.
|
||||
func (s *Session) PollOut(timeout time.Duration) ([]proto.OutMessage, bool) {
|
||||
return s.PollOutUntil(nil, timeout)
|
||||
}
|
||||
|
||||
// PollOutUntil is PollOut that also gives up when done closes, taking
|
||||
// nothing: for a reader that has gone, so no output is lost on it.
|
||||
func (s *Session) PollOutUntil(done <-chan struct{}, timeout time.Duration) ([]proto.OutMessage, bool) {
|
||||
var batch []proto.OutMessage
|
||||
select {
|
||||
case m := <-s.out:
|
||||
batch = append(batch, m)
|
||||
case <-done:
|
||||
return nil, true
|
||||
case <-time.After(timeout):
|
||||
return nil, true
|
||||
case <-s.closed:
|
||||
|
||||
Reference in new issue
Block a user