Documentation
¶
Index ¶
- func SetLogger(l EslLogger)
- type Command
- type Connection
- func (con *Connection) Api(cmd string, args ...string) (string, error)
- func (con *Connection) Authenticate() error
- func (con *Connection) BgApi(cmd string, args ...string) (string, error)
- func (con *Connection) Close()
- func (con *Connection) ConnectRetry(mretries int) error
- func (con *Connection) Execute(app string, uuid string, params ...string) (*Event, error)
- func (con *Connection) ExecuteLooped(app string, uuid string, loops uint, params ...string) (*Event, error)
- func (con *Connection) ExecuteLoopedSync(app string, uuid string, loops uint, params ...string) (*Event, error)
- func (con *Connection) ExecuteSync(app string, uuid string, params ...string) (*Event, error)
- func (con *Connection) HandleEvents() error
- func (con *Connection) MustSendRecv(cmd string, args ...string) *Event
- func (con *Connection) SendEvent(cmd string, headers map[string]string, body []byte) (*Event, error)
- func (con *Connection) SendRecv(cmd string, args ...string) (*Event, error)
- func (con *Connection) Write(b []byte) (int, error)
- type ConnectionHandler
- type Error
- type EslLogger
- type Event
- type EventName
- type EventType
- type MIMEMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetLogger ¶ added in v1.0.1
func SetLogger(l EslLogger)
set logger for print esl package inner message output
why a logger interface?
first, we cannot distinguish the local error (event parse or others) or command reply error in one send-reply function, which means should handle local error locally, but we need to let the pkg user to decide where and how to print.
Types ¶
type Command ¶
type Connection ¶
type Connection struct { Handler ConnectionHandler Address string Password string Connected bool MaxRetries int Timeout time.Duration UserData interface{} // contains filtered or unexported fields }
func NewConnection ¶
func NewConnection(host, passwd string, handler ConnectionHandler) (*Connection, error)
func (*Connection) Api ¶
func (con *Connection) Api(cmd string, args ...string) (string, error)
send api to FreeSWITCH by event socket, already start with `api ` support esl.Error type-assert
func (*Connection) Authenticate ¶
func (con *Connection) Authenticate() error
Authenticate handles freeswitch esl authentication
func (*Connection) BgApi ¶
func (con *Connection) BgApi(cmd string, args ...string) (string, error)
send background command to FreeSWITCH by event socket, already start with `bgapi ` support esl.Error type-assert
func (*Connection) Close ¶
func (con *Connection) Close()
func (*Connection) ConnectRetry ¶
func (con *Connection) ConnectRetry(mretries int) error
func (*Connection) Execute ¶
call an app on the leg which uuid is param uuid support esl.Error type-assert
func (*Connection) ExecuteLooped ¶ added in v1.0.2
func (con *Connection) ExecuteLooped(app string, uuid string, loops uint, params ...string) (*Event, error)
call an app on the leg which uuid is param uuid and call params loops times support esl.Error type-assert
func (*Connection) ExecuteLoopedSync ¶ added in v1.0.2
func (con *Connection) ExecuteLoopedSync(app string, uuid string, loops uint, params ...string) (*Event, error)
call an app on the leg which uuid is param uuid this app will not be interrupted by other applications, and call params loops times support esl.Error type-assert
func (*Connection) ExecuteSync ¶
call an app on the leg which uuid is param uuid this app will not be interrupted by other applications support esl.Error type-assert
func (*Connection) HandleEvents ¶
func (con *Connection) HandleEvents() error
dead forloop, unless connection lost support esl.Error type-assert
func (*Connection) MustSendRecv ¶
func (con *Connection) MustSendRecv(cmd string, args ...string) *Event
must send and receive command, or fatal the process
func (*Connection) SendEvent ¶
func (con *Connection) SendEvent(cmd string, headers map[string]string, body []byte) (*Event, error)
send event to event socket support esl.Error type-assert
type ConnectionHandler ¶
type ConnectionHandler interface { OnConnect(con *Connection) OnEvent(con *Connection, ev *Event) OnDisconnect(con *Connection, ev *Event) OnClose(con *Connection) }
type Error ¶ added in v1.0.4
connection write/read may need a way to judge network error type here is the solution to:
- keep original error
- no SendRecv/Api/BgApi method signature modifications
if you want original error, please use type-switch
type EslLogger ¶ added in v1.0.1
type EslLogger interface { Printf(fmt string, v ...interface{}) Fatal(v ...interface{}) }
type Event ¶
type Event struct { UId string Name EventName App string AppData string Stamp int Type EventType Header MIMEMap Body MIMEMap RawBody []byte }
func (Event) Get ¶
Get retrieves the value of header from Event header or (if not found) from Event body. The value is returned unescaped and is empty if not found anywhere.
func (*Event) GetTextBody ¶
type EventName ¶
type EventName int
const ( CUSTOM EventName = iota CLONE CHANNEL_CREATE CHANNEL_DESTROY CHANNEL_STATE CHANNEL_CALLSTATE CHANNEL_ANSWER CHANNEL_HANGUP CHANNEL_HANGUP_COMPLETE CHANNEL_EXECUTE CHANNEL_EXECUTE_COMPLETE CHANNEL_HOLD CHANNEL_UNHOLD CHANNEL_BRIDGE CHANNEL_UNBRIDGE CHANNEL_PROGRESS CHANNEL_PROGRESS_MEDIA CHANNEL_OUTGOING CHANNEL_PARK CHANNEL_UNPARK CHANNEL_APPLICATION CHANNEL_ORIGINATE CHANNEL_UUID API LOG INBOUND_CHAN OUTBOUND_CHAN STARTUP SHUTDOWN PUBLISH UNPUBLISH TALK NOTALK SESSION_CRASH MODULE_LOAD MODULE_UNLOAD DTMF MESSAGE PRESENCE_IN NOTIFY_IN PRESENCE_OUT PRESENCE_PROBE MESSAGE_WAITING MESSAGE_QUERY ROSTER CODEC BACKGROUND_JOB DETECTED_SPEECH DETECTED_TONE PRIVATE_COMMAND HEARTBEAT TRAP ADD_SCHEDULE DEL_SCHEDULE EXE_SCHEDULE RE_SCHEDULE RELOADXML NOTIFY PHONE_FEATURE PHONE_FEATURE_SUBSCRIBE SEND_MESSAGE RECV_MESSAGE REQUEST_PARAMS CHANNEL_DATA GENERAL COMMAND SESSION_HEARTBEAT CLIENT_DISCONNECTED SERVER_DISCONNECTED SEND_INFO RECV_INFO RECV_RTCP_MESSAGE CALL_SECURE NAT RECORD_START RECORD_STOP PLAYBACK_START PLAYBACK_STOP CALL_UPDATE FAILURE SOCKET_DATA MEDIA_BUG_START MEDIA_BUG_STOP CONFERENCE_DATA_QUERY CONFERENCE_DATA CALL_SETUP_REQ CALL_SETUP_RESULT CALL_DETAIL DEVICE_STATE ALL )