MCPcopy
hub / github.com/nats-io/nats.go / wsEnqueueControlMsg

Method wsEnqueueControlMsg

ws.go:751–771  ·  view source on GitHub ↗
(needsLock bool, frameType wsOpCode, payload []byte)

Source from the content-addressed store, hash-verified

749}
750
751func (nc *Conn) wsEnqueueControlMsg(needsLock bool, frameType wsOpCode, payload []byte) {
752 // In some low-level unit tests it will happen...
753 if nc == nil {
754 return
755 }
756 if needsLock {
757 nc.mu.Lock()
758 defer nc.mu.Unlock()
759 }
760 wr, ok := nc.bw.w.(*websocketWriter)
761 if !ok {
762 return
763 }
764 fh, key := wsCreateFrameHeader(false, frameType, len(payload))
765 wr.ctrlFrames = append(wr.ctrlFrames, fh)
766 if len(payload) > 0 {
767 wsMaskBuf(key, payload)
768 wr.ctrlFrames = append(wr.ctrlFrames, payload)
769 }
770 nc.bw.flush()
771}
772
773func (nc *Conn) wsUpdateConnectionHeaders(req *http.Request) error {
774 var headers http.Header

Callers 1

handleControlFrameMethod · 0.80

Calls 3

wsCreateFrameHeaderFunction · 0.85
wsMaskBufFunction · 0.85
flushMethod · 0.80

Tested by

no test coverage detected