diff --git a/src/croc/croc.go b/src/croc/croc.go index a228fe2..60f50c4 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -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 diff --git a/src/croc/recipient.go b/src/croc/recipient.go index e3c0d08..a37b0af 100644 --- a/src/croc/recipient.go +++ b/src/croc/recipient.go @@ -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