MCPcopy Index your code
hub / github.com/github/copilot-sdk / dispatchEvent

Method dispatchEvent

go/session.go:1350–1362  ·  view source on GitHub ↗

dispatchEvent enqueues an event for delivery to user handlers and fires broadcast handlers concurrently. Broadcast work (tool calls, permission requests) is fired in a separate goroutine so it does not block the JSON-RPC read loop. User event handlers are delivered by a single consumer goroutine (p

(event SessionEvent)

Source from the content-addressed store, hash-verified

1348// are delivered by a single consumer goroutine (processEvents), guaranteeing
1349// serial, FIFO dispatch without blocking the read loop.
1350func (s *Session) dispatchEvent(event SessionEvent) {
1351 s.updateOpenCanvasesFromEvent(event)
1352 go s.handleBroadcastEvent(event)
1353
1354 // Send to the event channel in a closure with a recover guard.
1355 // Disconnect closes eventCh, and in Go sending on a closed channel
1356 // panics — there is no non-panicking send primitive. We only want
1357 // to suppress that specific panic; other panics are not expected here.
1358 func() {
1359 defer func() { recover() }()
1360 s.eventCh <- event
1361 }()
1362}
1363
1364// processEvents is the single consumer goroutine for the event channel.
1365// It invokes user handlers serially, in arrival order. Panics in individual

Callers 3

TestSession_OnFunction · 0.45
TestSession_CapabilitiesFunction · 0.45
handleSessionEventMethod · 0.45

Calls 2

handleBroadcastEventMethod · 0.95

Tested by 2

TestSession_OnFunction · 0.36
TestSession_CapabilitiesFunction · 0.36