0x19 / goesl

Freeswitch Event Socket Library wrapper for Go
https://godoc.org/github.com/0x19/goesl
MIT License
125 stars 124 forks source link

break with Gt new message: <nil> #7

Open aztrock opened 8 years ago

aztrock commented 8 years ago
package main

import (
    "flag"
    "fmt"
    . "github.com/0x19/goesl"
    "runtime"
    //"strings"
)

var (
    fshost   = flag.String("fshost", "localhost", "Freeswitch hostname. Default: localhost")
    fsport   = flag.Uint("fsport", 8021, "Freeswitch port. Default: 8021")
    password = flag.String("pass", "ClueCon", "Freeswitch password. Default: ClueCon")
    timeout  = flag.Int("timeout", 10, "Freeswitch conneciton timeout in seconds. Default: 10")
)

func main() {
    runtime.GOMAXPROCS(runtime.NumCPU())
    client, err := NewClient(*fshost, *fsport, *password, *timeout)
    if err != nil {
        Error("Error while creating new client: %s", err)
        return
    }
    go client.Handle()
    client.Send("events json ALL")
    for {
        msg, _ := client.ReadMessage()
        fmt.Printf("Gt new message: %+v\n", msg)
    }
}

break the flow and not received more messages

08:19:18.278 Debug ▶ DEBUG Waiting for connection message to be received ... Gt new message: 08:19:18.278 Debug ▶ DEBUG Waiting for connection message to be received ...