Browse Source

buffer input and bugfix

main
David Haukeness 3 years ago
parent
commit
00d3761412
  1. 19
      libkeybase.go

19
libkeybase.go

@ -87,18 +87,21 @@ func (a *apiPrimitive) _start(args ...string) (err error) { @@ -87,18 +87,21 @@ func (a *apiPrimitive) _start(args ...string) (err error) {
if err != nil {
return
}
// buffer the output string (input should only need one)
// buffer the I/O channels
a.Input = make(chan string, a.opts.ChannelCapacity)
a.Output = make(chan string, a.opts.ChannelCapacity)
// now we need to start a select where anything in the channel goes to stdin
go func() {
select {
case msg := <-a.Input:
_, err = keyIn.Write([]byte(msg))
if err != nil {
for {
select {
case msg := <-a.Input:
_, err = keyIn.Write([]byte(msg))
if err != nil {
return
}
case <-a.die:
return
}
case <-a.die:
return
}
}()
// then we need to start a loop where anything in the output goes to the channel
@ -134,7 +137,7 @@ type apiWriter struct { @@ -134,7 +137,7 @@ type apiWriter struct {
}
func (a *apiWriter) start() (err error) {
err = a._start("api", "listen")
err = a._start("chat", "api")
return
}

Loading…
Cancel
Save