Wait for response on socket when sending
It appears that signald doesn't like not being able to send something back on the socket.
This commit is contained in:
parent
9248417773
commit
599c65adb2
1 changed files with 15 additions and 0 deletions
|
@ -19,6 +19,7 @@ import (
|
|||
"log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"time"
|
||||
|
||||
"git.callpipe.com/finn/signald-go/signald"
|
||||
"git.callpipe.com/finn/signald-go/signald/client-protocol/v1"
|
||||
|
@ -59,6 +60,20 @@ var sendCmd = &cobra.Command{
|
|||
request.AttachmentFilenames = []string{attachment}
|
||||
}
|
||||
s.SendRequest(request)
|
||||
|
||||
timeout := 10
|
||||
|
||||
// Wait for the response
|
||||
c := make(chan signald.Response)
|
||||
|
||||
go s.Listen(c)
|
||||
select {
|
||||
case <-c:
|
||||
log.Println("Ok.")
|
||||
case <-time.After(1 * time.Second):
|
||||
// But timeout after a while
|
||||
log.Fatalf("Timeout after %d seconds\n", timeout)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue