MCPcopy Create free account
hub / github.com/coder/agentapi / Subscribe

Method Subscribe

lib/httpapi/events.go:272–282  ·  view source on GitHub ↗

Subscribe returns: - a subscription ID that can be used to unsubscribe. - a channel for receiving events. - a list of events that allow to recreate the state of the conversation right before the subscription was created.

()

Source from the content-addressed store, hash-verified

270// - a channel for receiving events.
271// - a list of events that allow to recreate the state of the conversation right before the subscription was created.
272func (e *EventEmitter) Subscribe() (int, <-chan Event, []Event) {
273 e.mu.Lock()
274 defer e.mu.Unlock()
275 stateEvents := e.currentStateAsEvents()
276
277 // Once a channel becomes full, it will be closed.
278 ch := make(chan Event, e.subscriptionBufSize)
279 e.chans[e.chanIdx] = ch
280 e.chanIdx++
281 return e.chanIdx - 1, ch, stateEvents
282}
283
284// Assumes the caller holds the lock.
285func (e *EventEmitter) unsubscribeInner(chanId int) {

Callers 3

TestEventEmitterFunction · 0.95
subscribeEventsMethod · 0.80
subscribeScreenMethod · 0.80

Calls 1

currentStateAsEventsMethod · 0.95

Tested by 1

TestEventEmitterFunction · 0.76