add window recipient prompt

This commit is contained in:
Zack Scholl 2018-10-17 18:14:45 -07:00
parent 4ee008225e
commit f9dfa6bc05
2 changed files with 20 additions and 0 deletions

View File

@ -57,6 +57,10 @@ type Croc struct {
StateString string
Bar *progressbar.ProgressBar
FileInfo models.FileStats
// special for window
WindowRecipientPrompt bool
WindowRecipientAccept bool
}
// Init will initiate with the default parameters

View File

@ -220,6 +220,22 @@ func (cr *Croc) receive(forceSend int, serverAddress string, tcpPorts []string,
return nil
}
}
if cr.WindowRecipientPrompt {
// wait until it switches to false
// the window should then set WindowRecipientAccept
for {
if !cr.WindowRecipientPrompt {
if cr.WindowRecipientAccept {
break
} else {
fmt.Fprintf(os.Stderr, "cancelling request")
c.WriteMessage(websocket.BinaryMessage, []byte("no"))
return nil
}
}
time.Sleep(10 * time.Millisecond)
}
}
// await file
// erase file if overwriting