|
@@ -79,7 +79,9 @@ func initOriginate(req *OriginateRequest, client *Client) *Originate {
|
|
|
client: client,
|
|
|
userEventChan: make(chan Event, 1),
|
|
|
}
|
|
|
- go res.listenEvents()
|
|
|
+ waiter := make(chan struct{})
|
|
|
+ go res.listenEvents(waiter)
|
|
|
+ <-waiter
|
|
|
return res
|
|
|
}
|
|
|
|
|
@@ -94,8 +96,9 @@ type Originate struct {
|
|
|
hangupCause byte
|
|
|
}
|
|
|
|
|
|
-func (s *Originate) listenEvents() {
|
|
|
+func (s *Originate) listenEvents(waiter chan<- struct{}) {
|
|
|
log.Println("AMI-LISTEN-EVENTS")
|
|
|
+ close(waiter)
|
|
|
defer log.Println("AMI-LISTENER-ORIGINATE-CLOSED")
|
|
|
for {
|
|
|
e, ok := <-s.eventChan
|