Skip to content

Commit

Permalink
README updated
Browse files Browse the repository at this point in the history
Updated README to reflect fix for supporting multiple Event values
in the same 'filter' command.

Github Issue #15
  • Loading branch information
praveenchourasia committed Jul 4, 2017
1 parent 5b60f0d commit 3309361
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions README.md
Expand Up @@ -22,10 +22,24 @@ import (
)
// Formats the event as map and prints it out
func printHeartbeat( eventStr, connId string ) {
func printHeartbeat( eventStr, connId string) {
// Format the event from string into Go's map type
eventMap := fsock.FSEventStrToMap(eventStr, []string{})
fmt.Printf("%v, connId: %s",eventMap, connId)
fmt.Printf("%v, connId: %s\n",eventMap, connId)
}
// Formats the event as map and prints it out
func printChannelAnswer( eventStr, connId string) {
// Format the event from string into Go's map type
eventMap := fsock.FSEventStrToMap(eventStr, []string{})
fmt.Printf("%v, connId: %s\n",eventMap, connId)
}
// Formats the event as map and prints it out
func printChannelHangup( eventStr, connId string) {
// Format the event from string into Go's map type
eventMap := fsock.FSEventStrToMap(eventStr, []string{})
fmt.Printf("%v, connId: %s\n",eventMap, connId)
}
func main() {
Expand All @@ -35,14 +49,23 @@ func main() {
l.Crit(fmt.Sprintf("Cannot connect to syslog:", errLog))
return
}
// No filters
evFilters := map[string]string{}
// We are interested in heartbeats, define handler for them
evHandlers := map[string][]func(string, string){"HEARTBEAT": []func(string, string){printHeartbeat}}
// Filters
evFilters := make(map[string][]string)
evFilters["Event-Name"] = append(evFilters["Event-Name"], "CHANNEL_ANSWER")
evFilters["Event-Name"] = append(evFilters["Event-Name"], "CHANNEL_HANGUP_COMPLETE")
// We are interested in heartbeats, channel_answer, channel_hangup define handler for them
evHandlers := map[string][]func(string, string){
"HEARTBEAT": {printHeartbeat},
"CHANNEL_ANSWER": {printChannelAnswer},
"CHANNEL_HANGUP_COMPLETE": {printChannelHangup},
}
fs, err := fsock.NewFSock("127.0.0.1:8021", "ClueCon", 10, evHandlers, evFilters, l, "wetsfnmretiewrtpj")
if err != nil {
l.Crit(fmt.Sprintf("FreeSWITCH error:", err))
return
return
}
fs.ReadEvents()
}
Expand Down

0 comments on commit 3309361

Please sign in to comment.