-
Notifications
You must be signed in to change notification settings - Fork 124
/
helpers.go
47 lines (38 loc) · 1.92 KB
/
helpers.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
42
43
44
45
46
47
// Copyright 2015 Nevio Vesic
// Please check out LICENSE file for more information about what you CAN and what you CANNOT do!
// Basically in short this is a free software for you to do whatever you want to do BUT copyright must be included!
// I didn't write all of this code so you could say it's yours.
// MIT License
package goesl
// Set - Helper that you can use to execute SET application against active ESL session
func (sc *SocketConnection) ExecuteSet(key string, value string, sync bool) (m *Message, err error) {
return sc.Execute("set", key+"="+value, sync)
}
// ExecuteHangup - Helper desgned to help with executing Answer against active ESL session
func (sc *SocketConnection) ExecuteAnswer(args string, sync bool) (m *Message, err error) {
return sc.Execute("answer", args, sync)
}
// ExecuteHangup - Helper desgned to help with executing Hangup against active ESL session
func (sc *SocketConnection) ExecuteHangup(uuid string, args string, sync bool) (m *Message, err error) {
if uuid != "" {
return sc.ExecuteUUID(uuid, "hangup", args, sync)
}
return sc.Execute("hangup", args, sync)
}
// BgApi - Helper designed to attach api in front of the command so that you do not need to write it
func (sc *SocketConnection) Api(command string) error {
return sc.Send("api " + command)
}
// BgApi - Helper designed to attach bgapi in front of the command so that you do not need to write it
func (sc *SocketConnection) BgApi(command string) error {
return sc.Send("bgapi " + command)
}
// Connect - Helper designed to help you handle connection. Each outbound server when handling needs to connect e.g. accept
// connection in order for you to do answer, hangup or do whatever else you wish to do
func (sc *SocketConnection) Connect() error {
return sc.Send("connect")
}
// Exit - Used to send exit signal to ESL. It will basically hangup call and close connection
func (sc *SocketConnection) Exit() error {
return sc.Send("exit")
}