one more i/o fix in door handler - prompt doesn't always have a newline
This commit is contained in:
parent
f371c01596
commit
97cc113329
11
main.go
11
main.go
@ -266,12 +266,6 @@ func doorHandler(ctx context.Context, c net.Conn, w *gaio.Watcher, menuwg *sync.
|
||||
defer menuwg.Done()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
const bannerText = "\r\nCOLOSSAL CAVE\r\n\r\n"
|
||||
|
||||
err := w.Write(ctx, c, []byte(bannerText))
|
||||
if err != nil {
|
||||
log.Printf("error writing to connection: %v\n", err)
|
||||
}
|
||||
|
||||
var inChan, _ chan gaio.OpResult
|
||||
var ok bool
|
||||
@ -354,10 +348,13 @@ func doorHandler(ctx context.Context, c net.Conn, w *gaio.Watcher, menuwg *sync.
|
||||
if l > 0 {
|
||||
w.Write(ctx, c, outBuf[:l])
|
||||
log.Printf("wrote %d bytes to watcher: %v\n", l, string(outBuf[:l]))
|
||||
if strings.Contains(string(outBuf[:l]), ">") {
|
||||
// a prompt appeared!
|
||||
waitingForInput = true
|
||||
}
|
||||
} else {
|
||||
// zero output? let's get some input?
|
||||
waitingForInput = true
|
||||
// waitingForInput = true
|
||||
w.Read(ctx, c, nil)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user