Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

outbound can't get event in real-time #15

Open
transtone opened this issue Feb 17, 2023 · 0 comments
Open

outbound can't get event in real-time #15

transtone opened this issue Feb 17, 2023 · 0 comments

Comments

@transtone
Copy link

when ReadEvent in outbound, it can't get the events in real-time, all events will send on just disconnect when use linger.
if not use linger, it can't get any event at all.

// Copyright 2013 Alexandre Fiori
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Server that accepts connections from FreeSWITCH and controls incoming calls.
package main

import (
	"fmt"
	"log"

	"github.com/fiorix/go-eventsocket/eventsocket"
)

// const audioFile = "/opt/freeswitch/sounds/en/us/callie/misc/8000/sorry.wav"
const audioFile = "/usr/share/freeswitch/sounds/music/8000/partita-no-3-in-e-major-bwv-1006-1-preludio.wav"

func main() {
	eventsocket.ListenAndServe(":9090", handler)
}

func handler(c *eventsocket.Connection) {
	fmt.Println("new client:", c.RemoteAddr())
	c.Send("connect")
	c.Send("myevents")
	c.Send("event plain ALL")
	c.Send("start_dtmf")
        c.Send("linger")
	c.Execute("answer", "", false)
	c.Execute("playback", audioFile, true)
	
	for {
		ev, err := c.ReadEvent()
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println("\nNew event")
		ev.PrettyPrint()
		if ev.Get("Application") == "playback" {
			if ev.Get("Application-Response") == "FILE PLAYED" {
				c.Send("exit")
			}
		}
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant