Documentation
¶
Index ¶
- Constants
- Variables
- func IsExistInSlice(s string, list []string) bool
- type Client
- type ESLConnection
- func (c *ESLConnection) Api(cmd string) (*ESLResponse, error)
- func (c *ESLConnection) Authenticate(ctx context.Context, password string) error
- func (c *ESLConnection) BgApi(cmd string) error
- func (c *ESLConnection) Close() error
- func (c *ESLConnection) Dial(protocol string, address string, timeout time.Duration) (net.Conn, error)
- func (c *ESLConnection) Exit(cmd string) error
- func (c *ESLConnection) ExitAndClose()
- func (c *ESLConnection) ParseResponse() (*ESLResponse, error)
- func (c *ESLConnection) ReadMessage() (*ESLResponse, error)
- func (c *ESLConnection) Send(cmd string) (*ESLResponse, error)
- func (c *ESLConnection) SendAsync(cmd string) error
- func (c *ESLConnection) SendEvent(eventHeaders []string) (*ESLResponse, error)
- func (c *ESLConnection) SendMsg(msg map[string]string, uuid, data string) (*ESLResponse, error)
- func (c *ESLConnection) SendWithContext(ctx context.Context, cmd string) (*ESLResponse, error)
- type ESLResponse
- type Logger
- type NilLogger
- type NormalLogger
- type Options
Constants ¶
const ( ContentType_AuthRequest = `auth/request` ContentType_Reply = `command/reply` ContentType_APIResponse = `api/response` ContentType_Disconnect = `text/disconnect-notice` // for event ContentType_EventPlain = `text/event-plain` ContentType_EventJSON = `text/event-json` ContentType_EventXML = `text/event-xml` )
const DEFAULT_TIMEOUT = time.Second * 60
const EndOfMessage = "\r\n\r\n"
Variables ¶
var ( ReadBufferSize = 1024 << 6 AllowedContentTypes = []string{ ContentType_AuthRequest, ContentType_Reply, ContentType_APIResponse, ContentType_Disconnect, ContentType_EventPlain, ContentType_EventJSON, ContentType_EventXML, } )
var DefaultOptions = Options{ Context: context.Background(), Logger: NormalLogger{}, }
DefaultOptions - The default options used for creating the connection
Functions ¶
func IsExistInSlice ¶
Types ¶
type Client ¶
type Client struct { *ESLConnection Protocol string Address string Password string Timeout int OnDisconnect func() }
Client - Used to create an inbound connection to Freeswitch server In order to originate call, transfer, or something amazing ...
func NewClient ¶
NewClient - Init new client connection, this will establish connection and attempt to authenticate against connected freeswitch server
func (*Client) EstablishConnection ¶
func (client *Client) EstablishConnection() (*ESLConnection, error)
EstablishConnection - Will attempt to establish connection against freeswitch and create new connection
type ESLConnection ¶
type ESLConnection struct {
// contains filtered or unexported fields
}
ESLConnection
func (*ESLConnection) Api ¶
func (c *ESLConnection) Api(cmd string) (*ESLResponse, error)
func (*ESLConnection) Authenticate ¶
func (c *ESLConnection) Authenticate(ctx context.Context, password string) error
Authenticate - Method used to authenticate client against freeswitch.
func (*ESLConnection) BgApi ¶
func (c *ESLConnection) BgApi(cmd string) error
func (*ESLConnection) Exit ¶
func (c *ESLConnection) Exit(cmd string) error
func (*ESLConnection) ExitAndClose ¶
func (c *ESLConnection) ExitAndClose()
ExitAndClose - Send exit command before close connection
func (*ESLConnection) ParseResponse ¶
func (c *ESLConnection) ParseResponse() (*ESLResponse, error)
func (*ESLConnection) ReadMessage ¶
func (c *ESLConnection) ReadMessage() (*ESLResponse, error)
ReadMessage - Read message from channel and return ESLResponse
func (*ESLConnection) Send ¶
func (c *ESLConnection) Send(cmd string) (*ESLResponse, error)
Send - Send command and get response message
func (*ESLConnection) SendAsync ¶
func (c *ESLConnection) SendAsync(cmd string) error
SendAsync - Send command but don't get response message
func (*ESLConnection) SendEvent ¶ added in v1.0.3
func (c *ESLConnection) SendEvent(eventHeaders []string) (*ESLResponse, error)
SendEvent - Loop to passed event headers
func (*ESLConnection) SendMsg ¶ added in v1.0.5
func (c *ESLConnection) SendMsg(msg map[string]string, uuid, data string) (*ESLResponse, error)
SendEvent - Loop to passed event headers
func (*ESLConnection) SendWithContext ¶
func (c *ESLConnection) SendWithContext(ctx context.Context, cmd string) (*ESLResponse, error)
SendWithContext - Send command and get response message with deadline
type ESLResponse ¶
func (*ESLResponse) GetHeader ¶
func (r *ESLResponse) GetHeader(header string) string
GetHeader - Get header value
func (*ESLResponse) GetReply ¶
func (r *ESLResponse) GetReply() string
GetReply - Get reply value in header
func (*ESLResponse) HasHeader ¶
func (r *ESLResponse) HasHeader(header string) bool
GetReply - Check value in header
type NormalLogger ¶
type NormalLogger struct{}
func (NormalLogger) Debug ¶
func (l NormalLogger) Debug(format string, args ...interface{})
func (NormalLogger) Error ¶
func (l NormalLogger) Error(format string, args ...interface{})
func (NormalLogger) Info ¶
func (l NormalLogger) Info(format string, args ...interface{})
func (NormalLogger) Warn ¶
func (l NormalLogger) Warn(format string, args ...interface{})