MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / writeMessage

Method writeMessage

pkg/web/sse/ssehandler.go:169–185  ·  view source on GitHub ↗

writeMessage writes a message to the SSE stream

(msg SSEMessage)

Source from the content-addressed store, hash-verified

167
168// writeMessage writes a message to the SSE stream
169func (h *SSEHandlerCh) writeMessage(msg SSEMessage) error {
170 if h.ctx.Err() != nil {
171 return h.ctx.Err()
172 }
173 switch msg.Type {
174 case SSEMsgData:
175 return h.writeDirectly(msg.Data, SSEMsgData)
176 case SSEMsgEvent:
177 return h.writeEvent(msg.EventType, msg.Data)
178 case SSEMsgComment:
179 return h.writeDirectly(msg.Data, SSEMsgComment)
180 case SSEMsgError:
181 return h.writeDirectly(msg.Data, SSEMsgData)
182 default:
183 return fmt.Errorf("unknown message type: %s", msg.Type)
184 }
185}
186
187// isInitialized returns whether SetupSSE has been called
188func (h *SSEHandlerCh) isInitialized() bool {

Callers 1

writerLoopMethod · 0.95

Calls 3

writeDirectlyMethod · 0.95
writeEventMethod · 0.95
ErrMethod · 0.80

Tested by

no test coverage detected