-
Notifications
You must be signed in to change notification settings - Fork 39
/
inbound.go
41 lines (36 loc) · 1.15 KB
/
inbound.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* Copyright (c) 2020 Percipia
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* Contributor(s):
* Andrew Querol <aquerol@percipia.com>
*/
package main
import (
"context"
"fmt"
"github.com/percipia/eslgo"
"time"
)
func main() {
// Connect to FreeSWITCH
conn, err := eslgo.Dial("127.0.0.1:8021", "ClueCon", func() {
fmt.Println("Inbound Connection Disconnected")
})
if err != nil {
fmt.Println("Error connecting", err)
return
}
// Create a basic context
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
// Place the call in the background(bgapi) to user 100 and playback an audio file as the bLeg and no exported variables
response, err := conn.OriginateCall(ctx, true, eslgo.Leg{CallURL: "user/100"}, eslgo.Leg{CallURL: "&playback(misc/ivr-to_hear_screaming_monkeys.wav)"}, map[string]string{})
fmt.Println("Call Originated: ", response, err)
// Close the connection after sleeping for a bit
time.Sleep(60 * time.Second)
conn.ExitAndClose()
}