mirror of
https://github.com/PeernetOfficial/Cmd.git
synced 2026-07-18 11:27:51 +01:00
Console API: Subscribe to backend.Stdout.
This commit is contained in:
5
API.go
5
API.go
@@ -98,6 +98,11 @@ func apiConsole(backend *core.Backend) func(w http.ResponseWriter, r *http.Reque
|
||||
bufferR := bytes.NewBuffer(make([]byte, 0, 4096))
|
||||
bufferW := bytes.NewBuffer(make([]byte, 0, 4096))
|
||||
|
||||
// subscribe to any output sent to backend.Stdout
|
||||
subscribeID := backend.Stdout.Subscribe(bufferW)
|
||||
defer backend.Stdout.Unsubscribe(subscribeID)
|
||||
|
||||
// the terminate signal is used to signal the command handler in case the websocket is closed
|
||||
terminateSignal := make(chan struct{})
|
||||
defer close(terminateSignal)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user