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

Method writeDirectly

pkg/web/sse/ssehandler.go:195–214  ·  view source on GitHub ↗

writeDirectly writes data directly to the response writer

(data string, msgType SSEMessageType)

Source from the content-addressed store, hash-verified

193
194// writeDirectly writes data directly to the response writer
195func (h *SSEHandlerCh) writeDirectly(data string, msgType SSEMessageType) error {
196 if !h.isInitialized() {
197 panic("SSEHandlerCh not initialized - call SetupSSE first")
198 }
199 switch msgType {
200 case SSEMsgData:
201 _, err := fmt.Fprintf(h.w, "data: %s\n\n", data)
202 if err != nil {
203 return err
204 }
205 case SSEMsgComment:
206 _, err := fmt.Fprintf(h.w, ": %s\n\n", data)
207 if err != nil {
208 return err
209 }
210 default:
211 panic(fmt.Sprintf("unsupported direct write type: %s", msgType))
212 }
213 return h.flush()
214}
215
216// writeEvent writes an SSE event with optional event type
217func (h *SSEHandlerCh) writeEvent(eventType, data string) error {

Callers 2

writerLoopMethod · 0.95
writeMessageMethod · 0.95

Calls 2

isInitializedMethod · 0.95
flushMethod · 0.95

Tested by

no test coverage detected