MCPcopy Create free account
hub / github.com/LeoninCS/DevDesk / AddClient

Method AddClient

backend/internal/service/Markdown.go:94–111  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

92}
93
94func (d *Document) AddClient() chan string {
95 ch := make(chan string, 10)
96
97 d.mu.Lock()
98 d.Clients[ch] = struct{}{}
99 // 注册时先推一次当前内容
100 initial := d.Content
101 d.mu.Unlock()
102
103 // 将当前内容先发出去
104 go func() {
105 if initial != "" {
106 ch <- initial
107 }
108 }()
109
110 return ch
111}
112
113// RemoveClient 注销客户端,并关闭通道
114func (d *Document) RemoveClient(ch chan string) {

Callers 1

StreamDocumentMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected