X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/dd2320c6877939365caf79767b5244d86a288437..44c95f99098fa6c6acbfa82d4b6cbc6015eb6e39:/services/ws/handler.go diff --git a/services/ws/handler.go b/services/ws/handler.go index ca9231c986..f9f7f53edc 100644 --- a/services/ws/handler.go +++ b/services/ws/handler.go @@ -1,3 +1,7 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + package main import ( @@ -31,6 +35,7 @@ func (h *handler) Handle(ws wsConn, eventSource eventSource, newSession func(wsC h.setupOnce.Do(h.setup) ctx, cancel := context.WithCancel(ws.Request().Context()) + defer cancel() log := logger(ctx) incoming := eventSource.NewSink() @@ -52,6 +57,8 @@ func (h *handler) Handle(ws wsConn, eventSource eventSource, newSession func(wsC return } + // Receive websocket frames from the client and pass them to + // sess.Receive(). go func() { buf := make([]byte, 2<<20) for { @@ -83,6 +90,9 @@ func (h *handler) Handle(ws wsConn, eventSource eventSource, newSession func(wsC } }() + // Take items from the outgoing queue, serialize them using + // sess.EventMessage() as needed, and send them to the client + // as websocket frames. go func() { for { var ok bool