Skip to content

Commit

Permalink
add window recipient prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
schollz committed Oct 18, 2018
1 parent 4ee0082 commit f9dfa6b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/croc/croc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions src/croc/recipient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f9dfa6b

Please sign in to comment.