Browse Source

in progress

0x4a52466c696e74 11 months ago
parent
commit
2552c5121c
1 changed files with 4 additions and 2 deletions
  1. 4 2
      sip/asterisk/ami/originate.go

+ 4 - 2
sip/asterisk/ami/originate.go

@@ -21,16 +21,18 @@ func (s *Client) Originate(req *OriginateRequest) (*Originate, error) {
 		timeout = req.Timeout + time.Millisecond*500
 	}
 
+	res := initOriginate(req, s)
+
 	resp, check := s.Request(req.Request(), timeout)
 	if !check {
+		s.removeEventListener(req.uuid)
 		return nil, errors.New("Originate request timeout")
 	}
 	if resp.IsError() {
+		s.removeEventListener(req.uuid)
 		return nil, fmt.Errorf("Originate error: %v", resp.ErrorMessage())
 	}
 
-	res := initOriginate(req, s)
-
 	return res, nil
 }