goesl

package module
v1.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2019 License: MIT Imports: 15 Imported by: 0

README

License Build Status Go 1.3 Ready Go 1.4 Ready Go 1.5 Ready

##FreeSWITCH Event Socket Library Wrapper for Go

GoESL is a small wrapper around FreeSWITCH Event Socket Library written in Go.

Point of this library is to fully implement FreeSWITCH ESL and bring outbound server as inbound client to you, fellow Go developer :)

TODO?

You can find what still needs to be done at GoESL TODO

Examples

There are few different types of examples that can be found at GoESL Examples.

Feel free to suggest more examples :)

Contributions / Issues?

Please reach me over nevio.vesic@gmail.com or visit my website or submit new issue. I'd prefer tho if you would submit issue.

License

The MIT License (MIT)

Copyright (c) 2015 Nevio Vesic

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Size of buffer when we read from connection.
	// 1024 << 6 == 65536
	ReadBufferSize = 1024 << 6

	// Freeswitch events that we can handle (have logic for it)
	AvailableMessageTypes = []string{"auth/request", "text/disconnect-notice", "text/event-json", "text/event-plain", "api/response", "command/reply"}
)

Functions

func SetLogger

func SetLogger(l LoggerInterface)

SetLogger set global library logger

func StringInSlice

func StringInSlice(str string, list []string) bool

StringInSlice - Will check if string in list. This is equivalent to python if x in [] @TODO - What the fuck Nevio...

Types

type Client

type Client struct {
	*SocketConnection
}

Client - In case you need to do inbound dialing against freeswitch server in order to originate call or see sofia statuses or whatever else you came up with

func NewClient

func NewClient(aOpts ConnectOptions) (*Client, error)

NewClient - Will initiate new client that will establish connection and attempt to authenticate against connected freeswitch server

type ConnectOptions

type ConnectOptions struct {
	Host        string
	Port        uint
	Password    string
	DialTimeout time.Duration
}

ConnectOptions represent a cinitial connection options

type ESLConnection

type ESLConnection struct {
	*SocketConnection
}

ESLConnection wrapper for incoming connection

type ESLServer

type ESLServer struct {
	// contains filtered or unexported fields
}

ESLServer - In case you need to start server, this Struct have it covered

func NewESLServer

func NewESLServer() *ESLServer

NewESLServer - Will instanciate new outbound server

func (*ESLServer) Start

func (s *ESLServer) Start(aListenAddress string, aHandler HandlerFunc) error

Start - Will start new outbound server

func (*ESLServer) Stop

func (s *ESLServer) Stop()

Stop - Will close server connection once SIGTERM/Interrupt is received

type ErrorCouldNotReadBody

type ErrorCouldNotReadBody struct {
	// contains filtered or unexported fields
}

ErrorCouldNotReadBody ...

func (*ErrorCouldNotReadBody) Error

func (e *ErrorCouldNotReadBody) Error() string

type ErrorInvalidCommand

type ErrorInvalidCommand struct {
	// contains filtered or unexported fields
}

ErrorInvalidCommand fired when try to send invalid command

func (*ErrorInvalidCommand) Error

func (e *ErrorInvalidCommand) Error() string

type ErrorInvalidContentLength

type ErrorInvalidContentLength struct {
	// contains filtered or unexported fields
}

ErrorInvalidContentLength ...

func (*ErrorInvalidContentLength) Error

func (e *ErrorInvalidContentLength) Error() string

type ErrorInvalidPassword

type ErrorInvalidPassword struct {
	// contains filtered or unexported fields
}

ErrorInvalidPassword ...

func (*ErrorInvalidPassword) Error

func (e *ErrorInvalidPassword) Error() string

type ErrorInvalidServerAddr

type ErrorInvalidServerAddr struct {
	// contains filtered or unexported fields
}

ErrorInvalidServerAddr ...

func (*ErrorInvalidServerAddr) Error

func (e *ErrorInvalidServerAddr) Error() string

type ErrorReadMIMEHeaders

type ErrorReadMIMEHeaders struct {
	// contains filtered or unexported fields
}

ErrorReadMIMEHeaders ...

func (*ErrorReadMIMEHeaders) Error

func (e *ErrorReadMIMEHeaders) Error() string

type ErrorSendEvent

type ErrorSendEvent struct {
	// contains filtered or unexported fields
}

ErrorSendEvent ...

func (*ErrorSendEvent) Error

func (e *ErrorSendEvent) Error() string

type ErrorUnexpectedAuthHeader

type ErrorUnexpectedAuthHeader struct {
	// contains filtered or unexported fields
}

ErrorUnexpectedAuthHeader ...

func (*ErrorUnexpectedAuthHeader) Error

func (e *ErrorUnexpectedAuthHeader) Error() string

type ErrorUnmarshallJSON

type ErrorUnmarshallJSON struct {
	// contains filtered or unexported fields
}

ErrorUnmarshallJSON ...

func (*ErrorUnmarshallJSON) Error

func (e *ErrorUnmarshallJSON) Error() string

type ErrorUnsuccessfulReply

type ErrorUnsuccessfulReply struct {
	// contains filtered or unexported fields
}

ErrorUnsuccessfulReply ...

func (*ErrorUnsuccessfulReply) Error

func (e *ErrorUnsuccessfulReply) Error() string

type ErrorUnsupportedMessageType

type ErrorUnsupportedMessageType struct {
	// contains filtered or unexported fields
}

ErrorUnsupportedMessageType ...

func (*ErrorUnsupportedMessageType) Error

func (e *ErrorUnsupportedMessageType) Error() string

type ErrorWriteTiemout

type ErrorWriteTiemout struct {
	// contains filtered or unexported fields
}

ErrorWriteTiemout timeout error

func (*ErrorWriteTiemout) Error

func (e *ErrorWriteTiemout) Error() string

type HandlerFunc

type HandlerFunc func(*ESLConnection) bool

HandlerFunc hadler for incomming connection

type LoggerInterface

type LoggerInterface interface {
	Debug(message string, args ...interface{})
	Error(message string, args ...interface{})
	Info(message string, args ...interface{})
	Warning(message string, args ...interface{})
}

LoggerInterface base logger interface

type Message

type Message struct {
	Headers map[string]string
	Body    []byte
}

Message - Freeswitch Message that is received by GoESL. Message struct is here to help with parsing message and dumping its contents. In addition to that it's here to make sure received message is in fact message we wish/can support

func (*Message) Dump

func (m *Message) Dump() (resp string)

Dump - Will return message prepared to be dumped out. It's like prettify message for output

func (*Message) GetCallUUID

func (m *Message) GetCallUUID() string

GetCallUUID - Will return Caller-Unique-Id

func (*Message) GetHeader

func (m *Message) GetHeader(key string) string

GetHeader - Will return message header value, or "" if the key is not set.

func (*Message) String

func (m *Message) String() string

String - Will return message representation as string

type SocketConnection

type SocketConnection struct {
	// contains filtered or unexported fields
}

SocketConnection main connection against ESL

func (*SocketConnection) Api

func (sc *SocketConnection) Api(command string) error

Api - Helper designed to attach api in front of the command so that you do not need to write it

func (*SocketConnection) BgApi

func (sc *SocketConnection) BgApi(command string) error

BgApi - Helper designed to attach bgapi in front of the command so that you do not need to write it

func (*SocketConnection) Close

func (c *SocketConnection) Close() error

Close - Will close down net connection and return error if error happen

func (*SocketConnection) Errors

func (c *SocketConnection) Errors() chan error

Errors - returns error channel

func (*SocketConnection) Execute

func (c *SocketConnection) Execute(command, args string, sync bool) (err error)

Execute - Helper fuck to execute commands with its args and sync/async mode

func (*SocketConnection) ExecuteAnswer

func (sc *SocketConnection) ExecuteAnswer(args string, sync bool) (err error)

ExecuteAnswer - Helper desgned to help with executing Answer against active ESL session

func (*SocketConnection) ExecuteHangup

func (sc *SocketConnection) ExecuteHangup(uuid string, args string, sync bool) (err error)

ExecuteHangup - Helper desgned to help with executing Hangup against active ESL session

func (*SocketConnection) ExecuteSet

func (sc *SocketConnection) ExecuteSet(key string, value string, sync bool) error

ExecuteSet - Helper that you can use to execute SET application against active ESL session

func (*SocketConnection) ExecuteUUID

func (c *SocketConnection) ExecuteUUID(uuid string, command string, args string, sync bool) (err error)

ExecuteUUID - Helper fuck to execute uuid specific commands with its args and sync/async mode

func (*SocketConnection) Messages

func (c *SocketConnection) Messages() chan *Message

Messages - returns messages channel

func (*SocketConnection) Send

func (c *SocketConnection) Send(cmd string) error

Send - Will send raw message to open net connection

func (*SocketConnection) SendEvent

func (c *SocketConnection) SendEvent(eventHeaders []string) error

SendEvent - Will loop against passed event headers

func (*SocketConnection) SendMany

func (c *SocketConnection) SendMany(cmds []string) error

SendMany - Will loop against passed commands and return 1st error if error happens

func (*SocketConnection) SendMsg

func (c *SocketConnection) SendMsg(msg map[string]string, uuid, data string) error

SendMsg - Basically this func will send message to the opened connection

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL