Documentation ¶
Overview ¶
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. * * Contributor(s): * Andrew Querol <aquerol@percipia.com>
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. * * Contributor(s): * Andrew Querol <aquerol@percipia.com>
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. * * Contributor(s): * Andrew Querol <aquerol@percipia.com>
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. * * Contributor(s): * Andrew Querol <aquerol@percipia.com>
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. * * Contributor(s): * Andrew Querol <aquerol@percipia.com>
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. * * Contributor(s): * Andrew Querol <aquerol@percipia.com>
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. * * Contributor(s): * Andrew Querol <aquerol@percipia.com>
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. * * Contributor(s): * Andrew Querol <aquerol@percipia.com>
Index ¶
- Constants
- func BuildVars(format string, vars map[string]string) string
- func ListenAndServe(address string, handler OutboundHandler, opts *Options) error
- type Channels
- func (c *Channels) ApiResponseChannel() chan *RawResponse
- func (c *Channels) AuthRequestChannel() chan *RawResponse
- func (c *Channels) ByType(channelType string) chan *RawResponse
- func (c *Channels) Close()
- func (c *Channels) DisconnectChannel() chan *RawResponse
- func (c *Channels) EventJsonChannel() chan *RawResponse
- func (c *Channels) EventPlainChannel() chan *RawResponse
- func (c *Channels) EventXmlChannel() chan *RawResponse
- func (c *Channels) ReplyChannel() chan *RawResponse
- type Conn
- func (c *Conn) AnswerCall(ctx context.Context, uuid string) error
- func (c *Conn) ApiResponseChannel() chan *RawResponse
- func (c *Conn) AuthRequestChannel() chan *RawResponse
- func (c *Conn) Close()
- func (c *Conn) ConnectionId() string
- func (c *Conn) DebugEvents(w io.Writer) string
- func (c *Conn) DebugOff(id string)
- func (c *Conn) DisconnectChannel() chan *RawResponse
- func (c *Conn) EnableEvents(ctx context.Context) error
- func (c *Conn) EnterpriseOriginateCall(ctx context.Context, background bool, vars map[string]string, bLeg Leg, ...) (*RawResponse, error)
- func (c *Conn) EventJsonChannel() chan *RawResponse
- func (c *Conn) EventPlainChannel() chan *RawResponse
- func (c *Conn) EventXmlChannel() chan *RawResponse
- func (c *Conn) ExitAndClose()
- func (c *Conn) FinishedChannel() chan bool
- func (c *Conn) HangupCall(ctx context.Context, uuid, cause string) error
- func (c *Conn) OriginateCall(ctx context.Context, background bool, aLeg, bLeg Leg, vars map[string]string) (*RawResponse, error)
- func (c *Conn) Outbound() bool
- func (c *Conn) Phrase(ctx context.Context, uuid, macro string, times int, wait bool) (*RawResponse, error)
- func (c *Conn) PhraseWithArg(ctx context.Context, uuid, macro string, argument interface{}, times int, ...) (*RawResponse, error)
- func (c *Conn) Playback(ctx context.Context, uuid, audioArgs string, times int, wait bool) (*RawResponse, error)
- func (c *Conn) RegisterEventListener(channelUUID string, listener EventListener) string
- func (c *Conn) RemoveEventListener(channelUUID string, id string)
- func (c *Conn) ReplyChannel() chan *RawResponse
- func (c *Conn) RunningContext() context.Context
- func (c *Conn) Say(ctx context.Context, uuid, audioArgs string, times int, wait bool) (*RawResponse, error)
- func (c *Conn) SendCommand(ctx context.Context, command command.Command) (*RawResponse, error)
- func (c *Conn) SetFinishedChannel(finishedChannel chan bool)
- func (c *Conn) Speak(ctx context.Context, uuid, audioArgs string, times int, wait bool) (*RawResponse, error)
- func (c *Conn) WaitForDTMF(ctx context.Context, uuid string) (byte, error)
- type Event
- type EventListener
- type Leg
- type Options
- type OutboundHandler
- type RawResponse
- func (r RawResponse) ChannelUUID() string
- func (r RawResponse) GetHeader(header string) string
- func (r RawResponse) GetReply() string
- func (r RawResponse) GetVariable(variable string) string
- func (r RawResponse) GoString() string
- func (r RawResponse) HasHeader(header string) bool
- func (r RawResponse) IsOk() bool
- func (r RawResponse) String() string
Constants ¶
const ( TypeEventPlain = `text/event-plain` TypeEventJSON = `text/event-json` TypeEventXML = `text/event-xml` TypeReply = `command/reply` TypeAPIResponse = `api/response` TypeAuthRequest = `auth/request` TypeDisconnect = `text/disconnect-notice` )
const EndOfMessage = "\r\n\r\n"
const (
EventListenAll = "ALL"
)
Variables ¶
This section is empty.
Functions ¶
func ListenAndServe ¶
func ListenAndServe(address string, handler OutboundHandler, opts *Options) error
ListenAndServe start listener with given options
Types ¶
type Channels ¶
type Channels struct {
// contains filtered or unexported fields
}
func (*Channels) ApiResponseChannel ¶
func (c *Channels) ApiResponseChannel() chan *RawResponse
func (*Channels) AuthRequestChannel ¶
func (c *Channels) AuthRequestChannel() chan *RawResponse
func (*Channels) ByType ¶
func (c *Channels) ByType(channelType string) chan *RawResponse
func (*Channels) DisconnectChannel ¶
func (c *Channels) DisconnectChannel() chan *RawResponse
func (*Channels) EventJsonChannel ¶
func (c *Channels) EventJsonChannel() chan *RawResponse
func (*Channels) EventPlainChannel ¶
func (c *Channels) EventPlainChannel() chan *RawResponse
func (*Channels) EventXmlChannel ¶
func (c *Channels) EventXmlChannel() chan *RawResponse
func (*Channels) ReplyChannel ¶
func (c *Channels) ReplyChannel() chan *RawResponse
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn ...
func NewConnection ¶
func (*Conn) AnswerCall ¶
HangupCall - A helper to answer a call synchronously
func (*Conn) ApiResponseChannel ¶
func (c *Conn) ApiResponseChannel() chan *RawResponse
func (*Conn) AuthRequestChannel ¶
func (c *Conn) AuthRequestChannel() chan *RawResponse
func (*Conn) ConnectionId ¶
func (*Conn) DebugEvents ¶
DebugEvents - A helper that will output all events to a logger
func (*Conn) DisconnectChannel ¶
func (c *Conn) DisconnectChannel() chan *RawResponse
func (*Conn) EnterpriseOriginateCall ¶
func (c *Conn) EnterpriseOriginateCall(ctx context.Context, background bool, vars map[string]string, bLeg Leg, aLegs ...Leg) (*RawResponse, error)
EnterpriseOriginateCall - Calls the originate function in FreeSWITCH using the enterprise method for calling multiple legs ":_:" If you want variables for each leg independently set them in the aLeg and bLeg strings Arguments: ctx context.Context for supporting context cancellation, background bool should we wait for the origination to complete vars map[string]string, channel variables to be passed to originate for both legs, contained in <> bLeg string The bLeg of the call aLegs ...string variadic argument for each aLeg to call
func (*Conn) EventJsonChannel ¶
func (c *Conn) EventJsonChannel() chan *RawResponse
func (*Conn) EventPlainChannel ¶
func (c *Conn) EventPlainChannel() chan *RawResponse
func (*Conn) EventXmlChannel ¶
func (c *Conn) EventXmlChannel() chan *RawResponse
func (*Conn) ExitAndClose ¶
func (c *Conn) ExitAndClose()
func (*Conn) FinishedChannel ¶
func (*Conn) HangupCall ¶
HangupCall - A helper to hangup a call asynchronously
func (*Conn) OriginateCall ¶
func (c *Conn) OriginateCall(ctx context.Context, background bool, aLeg, bLeg Leg, vars map[string]string) (*RawResponse, error)
OriginateCall - Calls the originate function in FreeSWITCH. If you want variables for each leg independently set them in the aLeg and bLeg Arguments: ctx context.Context for supporting context cancellation, background bool should we wait for the origination to complete aLeg, bLeg Leg The aLeg and bLeg of the call respectively vars map[string]string, channel variables to be passed to originate for both legs, contained in {}
func (*Conn) Phrase ¶
func (c *Conn) Phrase(ctx context.Context, uuid, macro string, times int, wait bool) (*RawResponse, error)
Phrase - Executes the mod_dptools phrase app
func (*Conn) PhraseWithArg ¶
func (c *Conn) PhraseWithArg(ctx context.Context, uuid, macro string, argument interface{}, times int, wait bool) (*RawResponse, error)
PhraseWithArg - Executes the mod_dptools phrase app with arguments
func (*Conn) Playback ¶
func (c *Conn) Playback(ctx context.Context, uuid, audioArgs string, times int, wait bool) (*RawResponse, error)
Playback - Executes the mod_dptools playback app
func (*Conn) RegisterEventListener ¶
func (c *Conn) RegisterEventListener(channelUUID string, listener EventListener) string
RegisterEventListener ...
func (*Conn) RemoveEventListener ¶
RemoveEventListener ..
func (*Conn) ReplyChannel ¶
func (c *Conn) ReplyChannel() chan *RawResponse
func (*Conn) RunningContext ¶
func (*Conn) Say ¶
func (c *Conn) Say(ctx context.Context, uuid, audioArgs string, times int, wait bool) (*RawResponse, error)
Say - Executes the mod_dptools say app
func (*Conn) SendCommand ¶
func (*Conn) SetFinishedChannel ¶
type Event ¶
type Event struct { Headers textproto.MIMEHeader Body []byte }
type EventListener ¶
type EventListener func(event *Event)
type Leg ¶
Leg This struct is used to specify the individual legs of a call for the originate helpers
type Options ¶
type Options struct { //Allow for context timout. 0 will mean indefinite Timeout time.Duration `json:"duration"` // Defaults to "tcp" // Known networks are "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only), // "udp", "udp4" (IPv4-only), "udp6" (IPv6-only), "ip", "ip4" // (IPv4-only), "ip6" (IPv6-only), "unix", "unixgram" and // "unixpacket". Network string `json:"network"` Logger zerolog.Logger OnDisconnect func(string) }
Options allow of customizing listener
type OutboundHandler ¶
type OutboundHandler func(ctx context.Context, conn *Conn, connectResponse *RawResponse)
type RawResponse ¶
type RawResponse struct { Headers textproto.MIMEHeader Body []byte }
RawResponse This struct contains all response data from FreeSWITCH
func (RawResponse) ChannelUUID ¶
func (r RawResponse) ChannelUUID() string
ChannelUUID Helper to get the channel UUID. Calls GetHeader internally
func (RawResponse) GetHeader ¶
func (r RawResponse) GetHeader(header string) string
GetHeader Helper function that calls RawResponse.Headers.Get. Result gets passed through url.PathUnescape
func (RawResponse) GetReply ¶
func (r RawResponse) GetReply() string
GetReply Helper to get the Reply text from FreeSWITCH, uses the Reply-Text header primarily. Also will use the body if the Reply-Text header does not exist, this can be the case for TypeAPIResponse
func (RawResponse) GetVariable ¶
func (r RawResponse) GetVariable(variable string) string
GetVariable Helper function to get "Variable_" headers. Calls GetHeader internally
func (RawResponse) GoString ¶
func (r RawResponse) GoString() string
GoString Implement the GoStringer interface for pretty printing (%#v)
func (RawResponse) HasHeader ¶
func (r RawResponse) HasHeader(header string) bool
HasHeader Helper to check if the RawResponse has a header
func (RawResponse) IsOk ¶
func (r RawResponse) IsOk() bool
IsOk Helper to check response status, uses the Reply-Text header primarily. Calls GetReply internally
func (RawResponse) String ¶
func (r RawResponse) String() string
String Implement the Stringer interface for pretty printing
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v.
|
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. |
call
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v.
|
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. |
example
|
|
events
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v.
|
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. |
inbound
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v.
|
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. |
outbound
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v.
|
* Copyright (c) 2020 Percipia * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. |