Stop stops the HTTP server
(ctx context.Context)
| 101 | |
| 102 | // Stop stops the HTTP server |
| 103 | func (b *WebBridge) Stop(ctx context.Context) error { |
| 104 | if b.cancel != nil { |
| 105 | b.cancel() |
| 106 | } |
| 107 | |
| 108 | // Close all SSE clients |
| 109 | b.sseMu.Lock() |
| 110 | for _, ch := range b.sseClients { |
| 111 | close(ch) |
| 112 | } |
| 113 | b.sseClients = make(map[string]chan *FrontendEvent) |
| 114 | b.sseMu.Unlock() |
| 115 | |
| 116 | if b.server != nil { |
| 117 | return b.server.Shutdown(ctx) |
| 118 | } |
| 119 | return nil |
| 120 | } |
| 121 | |
| 122 | // RegisterAgent registers an agent with the bridge |
| 123 | func (b *WebBridge) RegisterAgent(ag *agent.Agent) error { |