Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions launcher/jnlp/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,22 @@ func (launcher *Launcher) exec() error {
if launcher.gui.Closed() {
return errCancelled
}

if launcher.options != nil && launcher.options.StdoutHandler != nil {
pipe, err := cmd.StdoutPipe()
if err != nil {
return errors.Wrap(err, "failed to create stdout pipe to application")
}
go launcher.options.StdoutHandler(pipe)
}

if launcher.options != nil && launcher.options.StderrHandler != nil {
pipe, err := cmd.StderrPipe()
if err != nil {
return errors.Wrap(err, "failed to create stderr pipe to application")
}
go launcher.options.StderrHandler(pipe)
}
return cmd.Start()
}

Expand Down
11 changes: 11 additions & 0 deletions launcher/launcher.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package launcher

import (
"io"
"net/url"
"strings"

Expand All @@ -23,12 +24,22 @@ type Launcher interface {
SetLogFile(logFile string)
}

// OutputHandler is invoked with the read end of a pipe to which the Launcher forwards
// output (stdout or stderr). Each instance of an OutputHandler will be provided its own
// goroutine, so it may block as necessary.
type OutputHandler = func(pipe io.ReadCloser)

type Options struct {
IsRunningFromBrowser bool
JavaDir string
ShowConsole bool
DisableVerification bool
DisableVerificationSameOrigin bool

// If non-nil, processes output from stdout of the launched process
StdoutHandler OutputHandler
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative to this would be to add it to the interface. I chose the options to limit the requirements of the interface, but I'm good with either approach.

// If non-nil, processes output from stderr of the launched process
StderrHandler OutputHandler
}

func RegisterProtocol(scheme string, launcher Launcher) {
Expand Down