-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a basic README and add an Inbound example.
- Loading branch information
Showing
3 changed files
with
108 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# eslgo | ||
eslgo is a [FreeSWITCH™](https://freeswitch.com/) ESL library for GoLang | ||
|
||
## Install | ||
``` | ||
go get github.com/percipia/eslgo | ||
``` | ||
``` | ||
github.com/percipia/eslgo v1.2.1 | ||
``` | ||
|
||
## Overview | ||
- Inbound ESL Connections | ||
- Outbound ESL Server | ||
- Context Support | ||
- Basic Helpers for common tasks | ||
- DTMF | ||
- Call origination | ||
- Call answer/hangup | ||
- Audio playback | ||
|
||
## Examples | ||
There are some buildable examples under the `example` directory as well | ||
### Outbound ESL Server | ||
```go | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/percipia/eslgo" | ||
"log" | ||
"time" | ||
) | ||
|
||
func main() { | ||
log.Fatalln(eslgo.ListenAndServe(":8084", handleConnection)) | ||
} | ||
|
||
func handleConnection(ctx context.Context, conn *eslgo.Conn, response *eslgo.RawResponse) { | ||
fmt.Printf("Got connection! %#v\n", response) | ||
_ = conn.EnableEvents(ctx) | ||
originationUUID, response, err := conn.OriginateCall(ctx, "user/100", "&playback(misc/ivr-to_hear_screaming_monkeys.wav)", map[string]string{}) | ||
fmt.Println("Call Originated: ", originationUUID, response, err) | ||
} | ||
``` | ||
## Inbound ESL Client | ||
```go | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/percipia/eslgo" | ||
"time" | ||
) | ||
|
||
func main() { | ||
conn, err := eslgo.Dial("127.0.0.1", "ClueCon", func() { | ||
fmt.Println("Inbound Connection Done") | ||
}) | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), 5 * time.Minute) | ||
defer cancel() | ||
|
||
_ = conn.EnableEvents(ctx) | ||
originationUUID, response, err := conn.OriginateCall(ctx, "user/100", "&playback(misc/ivr-to_hear_screaming_monkeys.wav)", map[string]string{}) | ||
fmt.Println("Call Originated: ", originationUUID, response, err) | ||
|
||
time.Sleep(60 * time.Second) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* 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 <[email protected]> | ||
*/ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"gitlab.percipia.com/libs/go/freeswitchesl" | ||
"time" | ||
) | ||
|
||
func main() { | ||
conn, err := freeswitchesl.Dial("127.0.0.1", "ClueCon", func() { | ||
fmt.Println("Inbound Connection Done") | ||
}) | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) | ||
defer cancel() | ||
|
||
_ = conn.EnableEvents(ctx) | ||
originationUUID, response, err := conn.OriginateCall(ctx, "user/100", "&playback(misc/ivr-to_hear_screaming_monkeys.wav)", map[string]string{}) | ||
fmt.Println("Call Originated: ", originationUUID, response, err) | ||
|
||
time.Sleep(60 * time.Second) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters