glivo

package module
v0.0.0-...-dc63708 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2015 License: MIT Imports: 13 Imported by: 0

README

glivo

Framework for building interactive telephony -Freeswitch- apps on Go Lang

glivo es

glivo es un framework para la construccion de applicaciones de telefonia en Freeswitch.

NO ACTO PARA PRODUCCION, AUN

Uso

Para ejemplos mirar: https://github.com/bit4bit/glivo-examples

TODO

  • temporizadores en los eventos y generacion de errores
  • Pruebas de comportamiento
  • Compatible con PlivoFramework

EJEMPLOS

func HandleCall(call *glivo.Call, data interface{}) {
	call.WaitAnswer()
	call.Answer()
	.....
	call.Hangup()
}

//iniciar glivo en el puerto e interfaz deseada
fsout, err := glivo.Listen(*clientIP, logger)
if err != nil {
	logger.Fatal(err.Error())
	os.Exit(1)
}
defer func() {
	fsout.Stop()
}()
go fsout.Serve(HandleCall, nil)

o para un manejador

func HandleCall(call *glivo.Call, data interface{}) {
	call.WaitAnswer()
	call.Answer()
	.....
	call.Hangup()
}

//iniciar glivo en el puerto e interfaz deseada
glivo.ListenAndServe(*clientIP, logger, HandleCall, nil)

Documentation

Overview

Call representa la conexion a la llamada iniciada o bien el acceso Outbound de Freeswitch, donde se puede controlar o dirigir el IVR.

http://wiki.freeswitch.org/wiki/Event_Socket_Outbound

Application:bridge EventName:CHANNEL_HANGUP EventName:CHANNEL_EXECUTE_COMPLETE Application:bridge Variable_bridge_hangup_cause:NORMAL_CLEARING Variable_dialstatus:DONTCALL Channel-Call-State:HELD Variable_originate_disposition:CALL_REJECTED Hangup-Cause:CALL_REJECTED

Implemanta Respuesta para Freeswitch Outbound e Inbound La idea inicial, es hacer un clon de plivoframework sencillo pero la diferencia es que recibe todo el mensaje o IVR y lo ejecuta

Index

Constants

View Source
const CALL_MAX_QUEUE_EVENTS = 77

Cantidad maxima antes de bloquear la gorutina aqui espero que no se retarde tanto para llenar la QUEUE

Variables

This section is empty.

Functions

func DispatcherEvents

func DispatcherEvents(call *Call)

func HandleCall

func HandleCall(call *Call, buf *bufio.Reader,
	replyCh chan CommandStatus, stopedCall chan bool)

func Listen

func Listen(laddr string, logger *log.Logger) (*server, error)

Crea el servidor en la interfaz y puerto seleccionado

func ListenAndserve

func ListenAndserve(laddr string, logger *log.Logger, handler HandlerCall,
	userData interface{}) error

Types

type Call

type Call struct {
	Conn net.Conn

	//UUID de la llamada
	UUID string

	//Header cabezera
	Header map[string]string

	//Variable variables en la llamada
	Variable map[string]string

	//Caller quien llama
	Caller *Channel

	//Closed cuando la llamada a sido finalizada
	Closed bool
	// contains filtered or unexported fields
}

La llamada que se controla actualmente Para mas procedimientos mirar chan/ y dptools/

func NewCall

func NewCall(conn *net.Conn, header textproto.MIMEHeader,
	replyChan chan CommandStatus, logger *log.Logger) *Call

NewCall crea nueva llamada en conexion

func (*Call) AddActionHandle

func (call *Call) AddActionHandle(hl HandlerEvent)

func (*Call) Answer

func (call *Call) Answer()

Contesta http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_answer

func (*Call) Close

func (call *Call) Close()

Cierra llamada debe ser llamada siempre

func (*Call) DoneActionHandle

func (call *Call) DoneActionHandle(idx int)

func (*Call) Execute

func (call *Call) Execute(app string, arg string, lock bool)

Executa app

func (*Call) Hangup

func (call *Call) Hangup()

Cuelga la llamada, al recibir evento CHANNEL_EXECUTE_COMPLETE de hangup o bien respuesta del comando http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_hangup

func (*Call) OnceEventHandle

func (call *Call) OnceEventHandle(hl func(chan interface{}) HandlerEvent) chan interface{}

Espera un evento y se ejecuta el handler una sola vez

func (*Call) Playback

func (call *Call) Playback(url string)

Reproduce audio http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_playback

func (*Call) RegisterEventHandle

func (call *Call) RegisterEventHandle(hl HandlerEvent) int64

Registra observador a un evento

func (*Call) Reply

func (call *Call) Reply() CommandStatus

Espera el reply del comando ejecutado

func (*Call) ReplyChan

func (call *Call) ReplyChan() chan CommandStatus

func (*Call) SetVar

func (call *Call) SetVar(name string, value string)

func (*Call) UnregisterEventHandle

func (call *Call) UnregisterEventHandle(idx int64)

func (*Call) WaitAnswer

func (call *Call) WaitAnswer() <-chan interface{}

Bloquea gorutina esperando evento CHANNEL_ANSWER retorna el chan glivo.Event

func (*Call) WaitEventChan

func (call *Call) WaitEventChan(filter map[string]string) chan interface{}

Se espera un evento determinado

func (*Call) Write

func (call *Call) Write(p []byte) (int, error)

Write permite escribir directamente

type Channel

type Channel struct {
	Header map[string]string
	// contains filtered or unexported fields
}

func (*Channel) Close

func (session *Channel) Close()

Termina, cuelga la llamada actual

type CollectDTMFEventHandle

type CollectDTMFEventHandle struct {
	// contains filtered or unexported fields
}

Recolecta marcacion

func NewCollectDTMFEventHandle

func NewCollectDTMFEventHandle(wait chan string, numDigits int, validDigits string, terminator uint8) CollectDTMFEventHandle

func (CollectDTMFEventHandle) Filter

func (cl CollectDTMFEventHandle) Filter(ev Event) bool

func (CollectDTMFEventHandle) Handle

func (cl CollectDTMFEventHandle) Handle(ev Event)

type CommandStatus

type CommandStatus string

type Event

type Event struct {
	Content map[string]string
	// contains filtered or unexported fields
}

Representa un evento de Freeswitch Las claves estan Camelised

func EventFromMIME

func EventFromMIME(call *Call, mime textproto.MIMEHeader) Event

Crea evento apartir de el MIME leido

type HandlerCall

type HandlerCall func(call *Call, userData interface{})

HandlerCall active call

type HandlerEvent

type HandlerEvent interface {
	//Delimita el handler a que eventos trabajar
	//retornar +true+ si es el evento esperado
	Filter(Event) bool

	//Recibe evento y reacciona a este si fue aceptado en el filtro
	Handle(Event)
}

Permite llamar procedimiento cuando se cumpla el filro o bien cuando el evento cumpla las condiciones esperadas.

type WaitAnyEventHandle

type WaitAnyEventHandle struct {
	// contains filtered or unexported fields
}

Este permite esperar un evento determinado y bloquear la gorutina atraves del chan *wait* @todo como manejar un timeout por demora??

func NewWaitAnyEventHandle

func NewWaitAnyEventHandle(wait chan interface{}, filter []map[string]string) WaitAnyEventHandle

func (WaitAnyEventHandle) Filter

func (we WaitAnyEventHandle) Filter(ev Event) bool

func (WaitAnyEventHandle) Handle

func (we WaitAnyEventHandle) Handle(ev Event)

type WaitEventHandle

type WaitEventHandle struct {
	// contains filtered or unexported fields
}

Este permite esperar un evento determinado y bloquear la gorutina atraves del chan *wait* TODO como manejar un timeout por demora??

func NewWaitEventHandle

func NewWaitEventHandle(wait chan interface{}, filter map[string]string) WaitEventHandle

func (WaitEventHandle) Filter

func (we WaitEventHandle) Filter(ev Event) bool

func (WaitEventHandle) Handle

func (we WaitEventHandle) Handle(ev Event)

Directories

Path Synopsis
http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_bridge
http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_bridge

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL