Delete receiver key if sender is not present and not waiting Fixes #39

This commit is contained in:
Zack Scholl 2017-10-22 10:36:44 -06:00
parent 9c6d672272
commit f8505caa27
2 changed files with 7 additions and 1 deletions

View File

@ -253,8 +253,10 @@ func (c *Connection) runClient() error {
} else {
logger.Debugf("telling relay: %s", "r."+c.Code)
if c.Wait {
// tell server to wait for sender
sendMessage("r."+c.HashedCode+".0.0.0", connection)
} else {
// tell server to cancel if sender doesn't exist
sendMessage("c."+c.HashedCode+".0.0.0", connection)
}
}
@ -371,7 +373,7 @@ func (c *Connection) runClient() error {
fmt.Println("\nFile sent.")
} else { // Is a Receiver
if notPresent {
fmt.Println("Sender/Code not present")
fmt.Println("Sender is not ready. Use -wait to wait until sender connects.")
return nil
}
if !gotOK {

View File

@ -205,6 +205,10 @@ func (r *Relay) clientCommuncation(id int, connection net.Conn) {
r.connections.RUnlock()
if connectionType == "c" {
sendMessage("0-0-0-0.0.0.0", connection)
// sender is not ready so delete connection
r.connections.Lock()
delete(r.connections.potentialReceivers, key)
r.connections.Unlock()
return
}
time.Sleep(100 * time.Millisecond)