Categorygithub.com/luoyumin/eslgo
modulepackage
1.4.4
Repository: https://github.com/luoyumin/eslgo.git
Documentation: pkg.go.dev

# README

eslgo

PkgGoDev GitHub Workflow Status Go Report Card Total alerts GitHub license

eslgo is a FreeSWITCH™ ESL library for GoLang. eslgo was written from the ground up in idiomatic Go for use in our production products tested handling thousands of calls per second.

Install

go get github.com/luoyumin/eslgo
github.com/luoyumin/eslgo v1.4.3

Overview

  • Inbound ESL Connection
  • Outbound ESL Server
  • Event listeners by UUID or All events
    • Unique-Id
    • Application-UUID
    • Job-UUID
  • Context support for canceling requests
  • All command types abstracted out
    • You can also send custom data by implementing the Command interface
      • BuildMessage() string
  • 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

package main

import (
	"context"
	"fmt"
	"github.com/luoyumin/eslgo"
	"log"
)

func main() {
	// Start listening, this is a blocking function
	log.Fatalln(eslgo.ListenAndServe(":8084", handleConnection))
}

func handleConnection(ctx context.Context, conn *eslgo.Conn, response *eslgo.RawResponse) {
	fmt.Printf("Got connection! %#v\n", response)

	// Place the call in the foreground(api) to user 100 and playback an audio file as the bLeg and no exported variables
	response, err := conn.OriginateCall(ctx, false, 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)
}

Inbound ESL Client

package main

import (
	"context"
	"fmt"
	"github.com/luoyumin/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()
}

# Packages

* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v.
No description provided by the author

# Functions

BuildVars - A helper that builds channel variable strings to be included in various commands to FreeSWITCH.
Dial - Connects to FreeSWITCH ESL at the provided address and authenticates with the provided password.
* TODO: Review if we should have a rate limiting facility to prevent DoS attacks * For our use it should be fine since we only want to listen on localhost */ ListenAndServe - Open a new listener for outbound ESL connections from FreeSWITCH on the specified address with the provided connection handler.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

DefaultInboundOptions - The default options used for creating the inbound connection.
DefaultOptions - The default options used for creating the connection.
DefaultOutboundOptions - The default options used for creating the outbound connection.

# Structs

No description provided by the author
No description provided by the author
InboundOptions - Used to dial a new inbound ESL connection to FreeSWITCH.
Leg This struct is used to specify the individual legs of a call for the originate helpers.
No description provided by the author
No description provided by the author
Options - Generic options for an ESL connection, either inbound or outbound.
OutboundOptions - Used to open a new listener for outbound ESL connections from FreeSWITCH.
RawResponse This struct contains all response data from FreeSWITCH.

# Interfaces

No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author