Documentation ¶
Index ¶
- Constants
- Variables
- func CodeFromError(err error) int
- func IsOpenPattern(p string) bool
- func NewBridgeContext(ctx context.Context, b *Bridge) context.Context
- func NewBridgeContextWithKey(ctx context.Context, b *Bridge, name string) context.Context
- func NewChannelContext(ctx context.Context, c *Channel) context.Context
- func NewChannelContextWithKey(ctx context.Context, c *Channel, name string) context.Context
- func NewClientContext(ctx context.Context, c *Client) context.Context
- func NewClientContextWithKey(ctx context.Context, c *Client, name string) context.Context
- func Play(ctx context.Context, p Player, mediaURI string) error
- type AddChannelRequest
- type Application
- type ApplicationReplaced
- type AsteriskDate
- type AsteriskInfo
- type Bridge
- func (b *Bridge) Add(channelID string) error
- func (b *Bridge) AttachClient(a *Client)
- func (b *Bridge) Delete() error
- func (b *Bridge) GetClient() *Client
- func (b *Bridge) GetID() string
- func (b *Bridge) Play(mediaURI string) (string, error)
- func (b *Bridge) PlayWithID(id, mediaURI string) error
- func (b *Bridge) Record(name string, opts *RecordingOptions) (*LiveRecording, error)
- func (b *Bridge) Remove(channelID string) error
- type BridgeAttendedTransfer
- type BridgeBlindTransfer
- type BridgeCreated
- type BridgeDestroyed
- type BridgeEvent
- type BridgeMerged
- type BuildInfo
- type Bus
- type CallerId
- type Channel
- func (c *Channel) Answer() error
- func (c *Channel) AttachClient(a *Client)
- func (c *Channel) Busy() error
- func (c *Channel) Congestion() error
- func (c *Channel) Continue(context string, extension string, priority int64) error
- func (c *Channel) Get(name string) (string, error)
- func (c *Channel) GetClient() *Client
- func (c *Channel) GetID() string
- func (c *Channel) Hangup() error
- func (c *Channel) Hold() error
- func (c *Channel) IsAnswered() (bool, error)
- func (c *Channel) IsReal() bool
- func (c *Channel) MOH(mohClass string) error
- func (c *Channel) Mute(dir string) error
- func (c *Channel) Play(mediaUri string) (string, error)
- func (c *Channel) PlayWithID(id, mediaUri string) error
- func (c *Channel) Record(name string, opts *RecordingOptions) (*LiveRecording, error)
- func (c *Channel) Ring() error
- func (c *Channel) SendDTMF(dtmf string) error
- func (c *Channel) Set(name string, value string) error
- func (c *Channel) Silence() error
- func (c *Channel) Snoop() (string, error)
- func (c *Channel) StopMOH() error
- func (c *Channel) StopRing() error
- func (c *Channel) StopSilence() error
- func (c *Channel) Unhold() error
- func (c *Channel) Unmute(dir string) error
- type ChannelCallerId
- type ChannelConnectedLine
- type ChannelCreated
- type ChannelDestroyed
- type ChannelDialplan
- type ChannelDtmfReceived
- type ChannelEnteredBridge
- type ChannelEvent
- type ChannelHangupRequest
- type ChannelHold
- type ChannelLeftBridge
- type ChannelStateChange
- type ChannelTalkingFinished
- type ChannelTalkingStarted
- type ChannelUnhold
- type ChannelUserevent
- type ChannelVarset
- type Client
- func (c *Client) AddChannel(id string, req AddChannelRequest) error
- func (c *Client) AnswerChannel(channelId string) error
- func (c *Client) BridgeDelete(id string) error
- func (c *Client) BridgeStopMoh(id string) error
- func (c *Client) ChangeDeviceState(deviceName string, deviceState string) error
- func (c *Client) ChangeMailboxState(mailboxName string, oldMessages int, newMessages int) error
- func (c *Client) CheckDirection(dir *string) error
- func (c *Client) Close()
- func (c *Client) ContinueChannel(channelId string, req ContinueChannelRequest) error
- func (c *Client) ControlPlayback(playbackID string, operation string) error
- func (c *Client) CopyStoredRecording(recordingName string, destination string) (StoredRecording, error)
- func (c *Client) CreateBridge(req CreateBridgeRequest) (Bridge, error)
- func (c *Client) CreateChannel(req OriginateRequest) (Channel, error)
- func (c *Client) CreateChannelWithId(id string, req OriginateRequest) (Channel, error)
- func (c *Client) CreateUserEvent(eventName string, req CreateUserEventRequest) error
- func (c *Client) Delete(url string, ret interface{}, req string) error
- func (c *Client) DeleteDeviceState(deviceName string) error
- func (c *Client) DeleteMailbox(mailboxName string) error
- func (c *Client) DeleteStoredRecording(recordingName string) error
- func (c *Client) Get(url string, ret interface{}) error
- func (c *Client) GetApplication(applicationName string) (Application, error)
- func (c *Client) GetAsteriskInfo(only string) (*AsteriskInfo, error)
- func (c *Client) GetAsteriskVariable(variable string) (string, error)
- func (c *Client) GetBridge(id string) (Bridge, error)
- func (c *Client) GetChannel(channelId string) (Channel, error)
- func (c *Client) GetChannelVariable(channelId string, variable string) (Variable, error)
- func (c *Client) GetDeviceState(deviceName string) (DeviceState, error)
- func (c *Client) GetEndpoint(tech string, resource string) (Endpoint, error)
- func (c *Client) GetEndpointsByTech(tech string) ([]Endpoint, error)
- func (c *Client) GetEvents(app string) (Message, error)
- func (c *Client) GetLiveRecording(recordingName string) (*LiveRecording, error)
- func (c *Client) GetMailbox(mailboxName string) (Mailbox, error)
- func (c *Client) GetPlaybackDetails(playbackID string) (Playback, error)
- func (c *Client) GetSound(soundId string) (Sound, error)
- func (c *Client) GetStoredRecording(recordingName string) (StoredRecording, error)
- func (c *Client) HangupChannel(channelId string, reason string) error
- func (c *Client) HoldChannel(channelId string) error
- func (c *Client) ListApplications() ([]Application, error)
- func (c *Client) ListBridges() ([]Bridge, error)
- func (c *Client) ListChannels() ([]Channel, error)
- func (c *Client) ListDeviceStates() ([]DeviceState, error)
- func (c *Client) ListEndpoints() ([]Endpoint, error)
- func (c *Client) ListMailboxes() ([]Mailbox, error)
- func (c *Client) ListSounds(filters map[string]string) ([]Sound, error)
- func (c *Client) ListSoundsFiltered(filters map[string]string) ([]Sound, error)
- func (c *Client) ListStoredRecordings() ([]StoredRecording, error)
- func (c *Client) Listen(ctx context.Context) (err error)
- func (c *Client) MuteChannel(channelId string, direction string) error
- func (c *Client) MuteLiveRecording(recordingName string) error
- func (c *Client) NewBridge() (Bridge, error)
- func (c *Client) NewBridgeWithID(id string) (Bridge, error)
- func (c *Client) NewChannel(endpoint string, cid *CallerId, vars map[string]string) (Channel, error)
- func (c *Client) NewLocalChannel(endpoint string, cid *CallerId, vars map[string]string) (Channel, Channel, error)
- func (c *Client) NewOriginateRequest(endpoint string) OriginateRequest
- func (c *Client) PauseLiveRecording(recordingName string) error
- func (c *Client) PlayMOHToChannel(channelId string, mohClass string) error
- func (c *Client) PlayMedia(channelId, mediaUri string) (string, error)
- func (c *Client) PlayMusicOnHold(id string, class string) error
- func (c *Client) PlaySilenceToChannel(channelId string) error
- func (c *Client) PlayToBridge(id string, req PlayMediaRequest) (Playback, error)
- func (c *Client) PlayToBridgeByID(id string, playbackID string, req PlayMediaRequest) (Playback, error)
- func (c *Client) PlayToChannel(channelId string, req PlayMediaRequest) (Playback, error)
- func (c *Client) PlayToChannelById(channelId string, playbackId string, req PlayMediaRequest) (Playback, error)
- func (c *Client) Post(requestURL string, ret interface{}, req interface{}) error
- func (c *Client) Put(url string, ret interface{}, req interface{}) error
- func (c *Client) RecordBridge(id string, req *RecordRequest) (*LiveRecording, error)
- func (c *Client) RecordChannel(channelId string, req *RecordRequest) (*LiveRecording, error)
- func (c *Client) ReloadModule(name string) error
- func (c *Client) RemoveChannel(id string, channelID string) error
- func (c *Client) ResumeLiveRecording(recordingName string) error
- func (c *Client) RingChannel(channelId string) error
- func (c *Client) ScrapLiveRecording(recordingName string) error
- func (c *Client) SendDTMFToChannel(channelId string, req SendDTMFToChannelRequest) error
- func (c *Client) SendMessage(from, tech, resource, body string, vars map[string]string) error
- func (c *Client) SendMessageByUri(from, to, body string, vars map[string]string) error
- func (c *Client) SetAsteriskVariable(variable string, value string) error
- func (c *Client) SetChannelVariable(channelId string, variable string, value string) error
- func (c *Client) StartSnoopChannel(channelId string, req SnoopRequest) (Channel, error)
- func (c *Client) StartSnoopChannelById(channelId string, snoopId string, req SnoopRequest) (Channel, error)
- func (c *Client) StopHoldChannel(channelId string) error
- func (c *Client) StopLiveRecording(recordingName string) error
- func (c *Client) StopMohChannel(channelId string) error
- func (c *Client) StopPlayback(playbackID string) error
- func (c *Client) StopRinging(channelId string) error
- func (c *Client) StopSilenceChannel(channelId string) error
- func (c *Client) SubscribeApplication(applicationName string, eventSource string) (Application, error)
- func (c *Client) UnMuteChannel(channelId string, direction string) error
- func (c *Client) UnmuteLiveRecording(recordingName string) error
- func (c *Client) UnsubscribeApplication(applicationName string, eventSource string) (Application, error)
- func (c *Client) UpsertBridge(id string, req CreateBridgeRequest) (Bridge, error)
- type ConfigInfo
- type ContactInfo
- type ContactStatusChanged
- type ContinueChannelRequest
- type CreateBridgeRequest
- type CreateUserEventRequest
- type DeviceState
- type DeviceStateChanged
- type Dial
- type DialplanCEP
- type Endpoint
- type EndpointStateChange
- type Event
- type Eventer
- type FormatLangPair
- type LiveRecording
- func (l *LiveRecording) Delete() error
- func (l *LiveRecording) Duration() (dur time.Duration)
- func (l *LiveRecording) Mute() error
- func (l *LiveRecording) Pause() error
- func (l *LiveRecording) Resume() error
- func (l *LiveRecording) Scrap() error
- func (l *LiveRecording) SilenceDuration() (dur time.Duration)
- func (l *LiveRecording) Status() int
- func (l *LiveRecording) Stop() error
- func (l *LiveRecording) TalkingDuration() (dur time.Duration)
- func (l *LiveRecording) Unmute() error
- type Mailbox
- type Message
- type MessageRawer
- type MissingParams
- type Options
- type OriginateRequest
- type Peer
- type PeerStatusChange
- type PlayMediaRequest
- type Playback
- type PlaybackFinished
- type PlaybackOptions
- type PlaybackQueue
- func (pq *PlaybackQueue) Add(mediaURIs ...string)
- func (pq *PlaybackQueue) Flush()
- func (pq *PlaybackQueue) Play(ctx context.Context, p Player, opts *PlaybackOptions) error
- func (pq *PlaybackQueue) PlayAsync(ctx context.Context, p Player, opts *PlaybackOptions) chan error
- func (pq *PlaybackQueue) ReceivedDTMF() string
- type PlaybackStarted
- type Player
- type PlayerRecorder
- type RawMessage
- type RecordRequest
- type Recorder
- type RecordingFailed
- type RecordingFinished
- type RecordingOptions
- type RecordingStarted
- type RequestError
- type SendDTMFToChannelRequest
- type SetID
- type SnoopRequest
- type Sound
- type StasisEnd
- type StasisStart
- type StatusInfo
- type StoredRecording
- type Subscription
- type SystemInfo
- type TextMessage
- type TextMessageReceived
- type TextMessageVariable
- type Variable
Constants ¶
const ( MuteIn = "in" MuteOut = "out" MuteBoth = "both" )
Mute-related constants for use with the mute commands `MuteIn` mutes audio coming in to the channel from Asterisk `MuteOut` mutes audio coming out from the channel to Asterisk `MuteBoth` mutes audio in both directions
const ( // RecordInProgress indicates that a recording is still in progress RecordInProgress = iota // RecordCanceled indicates that a recording was canceled (by request) RecordCanceled // RecordFailed indicates that a recording failed RecordFailed // RecordFinished indicates that a recording finished normally RecordFinished // RecordHangup indicates that a recording was ended due to hangup RecordHangup )
const ALL string = "all"
ALL signifies that the subscriber wants all events
const AST_CAUSE_ACCESS_INFO_DISCARDED = 43
const AST_CAUSE_ANSWERED_ELSEWHERE = 26
const AST_CAUSE_BEARERCAPABILITY_NOTAUTH = 57
const AST_CAUSE_BEARERCAPABILITY_NOTAVAIL = 58
const AST_CAUSE_BEARERCAPABILITY_NOTIMPL = 65
const AST_CAUSE_CALL_AWARDED_DELIVERED = 7
const AST_CAUSE_CALL_REJECTED = 21
const AST_CAUSE_CHANNEL_UNACCEPTABLE = 6
const AST_CAUSE_CHAN_NOT_IMPLEMENTED = 66
const AST_CAUSE_DESTINATION_OUT_OF_ORDER = 27
const AST_CAUSE_FACILITY_NOT_IMPLEMENTED = 69
const AST_CAUSE_FACILITY_NOT_SUBSCRIBED = 50
const AST_CAUSE_FACILITY_REJECTED = 29
const AST_CAUSE_IE_NONEXIST = 99
const AST_CAUSE_INCOMING_CALL_BARRED = 54
const AST_CAUSE_INCOMPATIBLE_DESTINATION = 88
const AST_CAUSE_INTERWORKING = 127
const AST_CAUSE_INVALID_CALL_REFERENCE = 81
const AST_CAUSE_INVALID_IE_CONTENTS = 100
const AST_CAUSE_INVALID_MSG_UNSPECIFIED = 95
const AST_CAUSE_INVALID_NUMBER_FORMAT = 28
const AST_CAUSE_MANDATORY_IE_LENGTH_ERROR = 103
const AST_CAUSE_MANDATORY_IE_MISSING = 96
const AST_CAUSE_MESSAGE_TYPE_NONEXIST = 97
const AST_CAUSE_MISDIALLED_TRUNK_PREFIX = 5
const AST_CAUSE_NETWORK_OUT_OF_ORDER = 38
const AST_CAUSE_NORMAL_CIRCUIT_CONGESTION = 34
const AST_CAUSE_NORMAL_CLEARING = 16
const AST_CAUSE_NORMAL_TEMPORARY_FAILURE = 41
const AST_CAUSE_NORMAL_UNSPECIFIED = 31
const AST_CAUSE_NO_ANSWER = 19
const AST_CAUSE_NO_ROUTE_DESTINATION = 3
const AST_CAUSE_NO_ROUTE_TRANSIT_NET = 2
const AST_CAUSE_NO_USER_RESPONSE = 18
const AST_CAUSE_NUMBER_CHANGED = 22
const AST_CAUSE_NUMBER_PORTED_NOT_HERE = 14
const AST_CAUSE_OUTGOING_CALL_BARRED = 52
const AST_CAUSE_PRE_EMPTED = 8
const AST_CAUSE_PROTOCOL_ERROR = 111
const AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE = 102
const AST_CAUSE_REDIRECTED_TO_NEW_DESTINATION = 23
const AST_CAUSE_REQUESTED_CHAN_UNAVAIL = 44
const AST_CAUSE_RESPONSE_TO_STATUS_ENQUIRY = 30
const AST_CAUSE_SUBSCRIBER_ABSENT = 20
const AST_CAUSE_SWITCH_CONGESTION = 42
const AST_CAUSE_UNALLOCATED = 1
const AST_CAUSE_USER_BUSY = 17
const AST_CAUSE_WRONG_CALL_STATE = 101
const AST_CAUSE_WRONG_MESSAGE = 98
const AllDTMF = "0123456789ABCD*#"
AllDTMF is a string which contains all possible DTMF digits.
const AsteriskDateFormat = "2006-01-02T15:04:05.000-0700"
Variables ¶
var ( DefaultUsername = "ariTest" DefaultSecret = "ariDev" )
var ( // ExistsFail indicates that a recording should fail if the // given name already exists. ExistsFail = "fail" // ExistsOverwrite indicates that if a recording exists of // the same name, it should be overwritten. ExistsOverwrite = "overwrite" // ExistsAppend indicates that if a recording exists of the // same name, it should be appended to. ExistsAppend = "append" )
var ( // TerminateNever indicates that a recording should not be // ended on any DTMF tone. TerminateNever = "none" // TerminateAny indicates that a recording should be terminated // if any DTMF digit is received TerminateAny = "any" // TerminateStar indicates that a recording should be terminated // if a * DTMF character is received. TerminateStar = "*" // TerminateHash indicates that a recording should be terminated // if a # DTMF character is received. TerminateHash = "#" // TerminatePound indicates that a recording should be terminated // if a # DTMF character is received. TerminatePound = "#" )
var AsteriskCodec = websocket.Codec{
Marshal: marshal,
Unmarshal: unmarshal,
}
AsteriskCode is a websocket Codec for Asterisk messages
var BusChannelBuffer = 100
BusChannelBuffer defines the buffer size of the subscription channels
var DefaultClient = NewClient(&Options{
Application: "default",
Username: "ariTest",
Password: "ariDev",
})
var Logger = log15.New()
Logger
Logger defaults to a discard handler (null output). If you wish to enable logging, you can set your own handler like so:
ari.Logger.SetHandler(log15.StderrHandler)
var MaxIdleConnections = 20
MaxIdleConnections is the maximum number of idle web client connections to maintain.
var MaxPlaybackTime = 10 * time.Minute
MaxPlaybackTime is the maximum amount of time to allow for a playback to complete.
var PlaybackStartTimeout = 1 * time.Second
PlaybackStartTimeout is the time to allow for Asterisk to send the PlaybackStarted before giving up.
var RecordingStartTimeout = 1 * time.Second
RecordingStartTimeout is the amount of time to wait for a recording to start before declaring the recording to have failed.
var RequestTimeout = 2 * time.Second
RequestTimeout describes the maximum amount of time to wait for a response to any request.
Functions ¶
func CodeFromError ¶
CodeFromError extracts and returns the code from an error, or 0 if not found.
func IsOpenPattern ¶
IsOpenPattern determines whether the regular expression is open-ended (allows for an indeterminite number of trailing parts) or not.
func NewBridgeContext ¶
NewBridgeContext returns a context with the bridge attached
func NewBridgeContextWithKey ¶
NewBridgeContextWithKey returns a context with the bridge attached as the given key
func NewChannelContext ¶
NewChannelContext returns a context with the channel attached
func NewChannelContextWithKey ¶
NewChannelContext returns a context with the channel attached as the given key
func NewClientContext ¶
NewClientContext returns a context with the client attached
func NewClientContextWithKey ¶
NewClientContextWithKey returns a context with the client attached as the given key
Types ¶
type AddChannelRequest ¶
type AddChannelRequest struct { ChannelID string `json:"channel"` Role string `json:"role,omitempty"` }
AddChannelRequest is the structure to add a channel to a bridge. Only Channel is required. ChannelID field allows for comma-separated-values to add multiple channels.
type Application ¶
type Application struct { BridgeIDs []string `json:"bridge_ids"` // Subscribed BridgeIds ChannelIDs []string `json:"channel_ids"` // Subscribed ChannelIds DeviceNames []string `json:"device_names"` // Subscribed Device names EndpointIDs []string `json:"endpoint_ids"` // Subscribed Endpoints (tech/resource format) Name string `json:"name"` // Name of the application }
Application describes a Stasis (Ari) application
type ApplicationReplaced ¶
type ApplicationReplaced Event
ApplicationReplaced is a notification to the original application that notifications about this application are now going to a different WebSocket connection. There can only be a single websocket connection for each application at any given time.
type AsteriskDate ¶
Asterisk ARI does not supply a format that the built-in golang json date parser can use, so we have to write our own unmarshal routine for it
func (AsteriskDate) MarshalJSON ¶
func (d AsteriskDate) MarshalJSON() ([]byte, error)
func (AsteriskDate) String ¶
func (d AsteriskDate) String() string
func (*AsteriskDate) UnmarshalJSON ¶
func (d *AsteriskDate) UnmarshalJSON(data []byte) error
type AsteriskInfo ¶
type AsteriskInfo struct { BuildInfo BuildInfo `json:"build"` ConfigInfo ConfigInfo `json:"config"` StatusInfo StatusInfo `json:"status"` SystemInfo SystemInfo `json:"system"` }
AsteriskInfo describes a running asterisk system
type Bridge ¶
type Bridge struct { ID string `json:"id"` // Unique Id for this bridge Class string `json:"bridge"` // Class of the bridge (TODO: huh?) Type string `json:"bridge_type"` // Type of bridge (mixing, holding, dtmf_events, proxy_media) ChannelIDs []string `json:"channels"` // List of pariticipating channel ids Creator string `json:"creator"` // Creating entity of the bridge Name string `json:"name"` // The name of the bridge Technology string `json:"technology"` // Name of the bridging technology // contains filtered or unexported fields }
Bridge describes an Asterisk Bridge, the entity which merges media from one or more channels into a common audio output
func BridgeFromContext ¶
BridgeFromContext returns the default Bridge stored in the context
func BridgeFromContextWithKey ¶
BridgeFromContextWithKey returns the Bridge stored in the context
func (*Bridge) AttachClient ¶
AttachClient attaches the provided ARI client to the bridge
func (*Bridge) PlayWithID ¶
PlayWithID plays an audio uri to the bridge with the provided playback ID
func (*Bridge) Record ¶
func (b *Bridge) Record(name string, opts *RecordingOptions) (*LiveRecording, error)
Record starts recording the audio from a bridge to the given recording name.
type BridgeAttendedTransfer ¶
type BridgeAttendedTransfer struct { Event DestinationApplication string `json:"destination_application,omitempty"` DestinationBridge string `json:"desination_bridge,omitempty"` DestinationLinkFirstLeg Channel `json:"destination_link_first_leg,omitempty"` DestinationLinkSecondLeg Channel `json:"destination_link_second_leg,omitempty"` DestinationThreewayBridge Bridge `json:"destination_threeway_bridge,omitempty"` DestinationThreewayChannel Channel `json:"destination_threeway_channel,omitempty"` DestinationType string `json:"destination_type"` External bool `json:"is_external"` Result string `json:"result"` Transferee Channel `json:"transferee,omitempty"` TransferTarget Channel `json:"transfer_target,omitempty"` TransfererFirstLeg Channel `json:"transferer_first_leg"` TransfererFirstLegBridge Bridge `json:"transferer_first_leg_bridge,omitempty"` TransfererSecondLeg Channel `json:"transferer_second_leg"` TransfererSecondLegBridge Bridge `json:"transferer_second_leg_bridge,omitempty"` }
BridgeAttendedTransfer events signify that an attended transfer has occurred
type BridgeBlindTransfer ¶
type BridgeBlindTransfer struct { Event Bridge Bridge `json:"bridge,omitempty"` Channel Channel `json:"channel"` Context string `json:"context"` Extension string `json:"exten"` External bool `json:"external"` ReplaceChannel Channel `json:"external,omitempty"` Result string `json:"result"` Transferee Channel `json:"transferee,omitempty"` }
BridgeBlindTransfer events signify that a blind transfer has occurred
type BridgeCreated ¶
BridgeCreated events indicate a bridge has been created
type BridgeDestroyed ¶
BridgeDestroyed events indicate a bridge has been destroyed
type BridgeEvent ¶
BridgeEvent (meta) is an event which affects a bridge
type BridgeMerged ¶
type BridgeMerged struct { Event Bridge Bridge `json:"bridge"` // New bridge Bridge_from Bridge `json:"bridge_from"` // Old (independant) bridge -- TODO: verify this assumption }
BridgeMerged events indicate a bridge has been merged into another (bridge)
type BuildInfo ¶
type BuildInfo struct { Date string `json:"date"` Kernel string `json:"kernel"` Machine string `json:"machine"` Options string `json:"options"` Os string `json:"os"` User string `json:"user"` }
BuildInfo describes information about how Asterisk was built
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
Bus is an event bus for ARI events. It receives and redistributes events based on a subscription model.
func (*Bus) Once ¶
Once listens for the first event of the provided types, returning a channel which supplies that event.
func (*Bus) Stop ¶
func (b *Bus) Stop()
Stop the bus. Cancels all subscriptions and stops listening for events.
func (*Bus) Subscribe ¶
func (b *Bus) Subscribe(eTypes ...string) *Subscription
Subscribe returns a subscription to the given list of event types
type CallerId ¶
CallerId describes the name and number which identifies the caller to other endpoints
type Channel ¶
type Channel struct { Accountcode string `json:"accountcode"` Caller CallerId `json:"caller"` // CallerId of the calling endpoint Connected CallerId `json:"connected"` // CallerId of the connected line Creationtime AsteriskDate `json:"creationtime"` Dialplan DialplanCEP `json:"dialplan"` // Current location in the dialplan Id string `json:"id"` // Unique id for this channel (same as for AMI) Name string `json:"name"` // Name of this channel (tech/name-id format) State string `json:"state"` // State of the channel // contains filtered or unexported fields }
Channel describes a(n active) communication connection between Asterisk and an Endpoint
func ChannelFromContext ¶
ChannelFromContext returns the default Channel stored in the context
func ChannelFromContextWithKey ¶
ChannelFromContextWithKey returns the default Channel stored in the context
func (*Channel) AttachClient ¶
AttachClient attaches the provided ARI client to the channel
func (*Channel) Congestion ¶
Congestion hangs up the current channel with the "congestion" cause code
func (*Channel) IsAnswered ¶
IsAnswered checks the current state of the channel to see if it is "Up" (answered)
func (*Channel) Mute ¶
Mute mutes the channel in the given direction (one of "in", "out", or "both")
func (*Channel) Play ¶
Play initiates playback of the specified media uri to the channel, returning the Playback's Id
func (*Channel) PlayWithID ¶
PlayWithID initiates playback of the specified media uri with the provided playbackID to the channel.
func (*Channel) Record ¶
func (c *Channel) Record(name string, opts *RecordingOptions) (*LiveRecording, error)
Record starts recording the channel, returning the LiveRecording
func (*Channel) Snoop ¶
Snoop begins a snoop session and returns its id TODO: what is the channel being returned; do we need it?
func (*Channel) StopSilence ¶
StopSilence stops transmission of silence to channel
type ChannelCallerId ¶
type ChannelCallerId struct { Event Caller_presentation int `json:"caller_presentation"` // The numeric portion Caller_presentation_txt string `json:"caller_presentation_txt"` // The textual portion Channel Channel `json:"channel"` }
ChannelCallerId events indicate a channel's caller Id information has changed
type ChannelConnectedLine ¶
ChannelConnectedLine events indicate a channel has changed its connected line
type ChannelCreated ¶
ChannelCreated events indicate a channel has been created
type ChannelDestroyed ¶
type ChannelDestroyed struct { Event Cause int `json:"cause"` Cause_txt string `json:"cause_txt"` Channel Channel `json:"channel"` }
ChannelDestroyed events indicate a channel has been destroyed
type ChannelDialplan ¶
type ChannelDialplan struct { Event Channel Channel `json:"channel"` Dialplan_app string `json:"dialplan_app"` // The application which is to be executed Dialplan_app_data string `json:"dialplan_app_data"` // The data to be passed to the application }
ChannelDialplan events indicate a channel has changed its location in the dialplan
NOTE: This event also most likely implies the channel is leaving the control of this ARI application
type ChannelDtmfReceived ¶
type ChannelDtmfReceived struct { Event Channel Channel `json:"channel"` Digit string `json:"digit"` // The DTMF digit which was received (0-9A-E*#) Duration_ms int `json:"duration_ms"` // The duration of the DTMF tone, in milliseconds }
ChannelDtmfReceived events indicate a channel has received a DTMF tone.
NOTE: this event is sent at the _end_ of the DTMF tone (and there is no indication for the _start_ of the DTMF tone)
type ChannelEnteredBridge ¶
type ChannelEnteredBridge struct { Event Bridge Bridge `json:"bridge"` Channel Channel `json:"channel"` }
ChannelEngteredBridge events indicate that a channel has joined a bridge
type ChannelEvent ¶
ChannelEvent (meta) is an event which affects a channel
type ChannelHangupRequest ¶
type ChannelHangupRequest struct { Event Cause int `json:"cause,omitempty"` // Integer cause code Channel Channel `json:"channel"` Soft bool `json:"soft,omitempty"` // Whether the request was "soft" }
ChannelHangupRequest events indicate that a channel has received a hangup request
TODO: find out if the application is supposed to act on this, or whether this event is purely advisory
type ChannelHold ¶
type ChannelHold struct { Event Channel Channel `json:"channel"` MusicClass string `json:"musicclass"` // The music class being played to the held channel }
ChannelHold events indicate that a channel has been put on hold
type ChannelLeftBridge ¶
type ChannelLeftBridge struct { Event Bridge Bridge `json:"bridge"` Channel Channel `json:"channel"` }
ChannelLeftBridge events indicate that a channel has left a bridge
type ChannelStateChange ¶
ChannelStateChange events indicate that the state of a channel has changed
TODO: enumerate the possible channel states
type ChannelTalkingFinished ¶
type ChannelTalkingFinished struct { Event Channel Channel `json:"channel"` Duration int `json:"duration"` // Duration (in milliseconds) of the talking }
ChannelTalkingFinished events indicate that previously-detected talking on a channel is now absent
type ChannelTalkingStarted ¶
ChannelTalkingStarted events indicate that talking has been detected on a channel
type ChannelUnhold ¶
ChannelUnhold events indicate that a channel has removed from Hold
type ChannelUserevent ¶
type ChannelUserevent struct { Event Bridge Bridge `json:"bridge,omitempty"` Channel Channel `json:"channel,omitempty"` Endpoint Endpoint `json:"endpoint,omitempty"` Eventname string `json:"eventname"` // Name of the user event Userevent interface{} `json:"userevent"` // Custome data sent with the user event }
ChannelUserevent events are custom-formatted events which have been received
TODO: figure out if these include AMI user events, etc, and how the data is formatted
type ChannelVarset ¶
type ChannelVarset struct { Event Channel Channel `json:"channel,omitempty"` // If not present, variable is global Value string `json:"value"` // New value Variable string `json:"variable"` // Variable name }
ChannelVarset events indicate a channel variable has been set (or changed)
type Client ¶
type Client struct { Options *Options // client options WSConfig *websocket.Config // websocket connection configuration ReadyChan chan struct{} Bus *Bus // event bus TestMode bool // Client is in test mode: no actual HTTP requests will be made // contains filtered or unexported fields }
Client describes an ARI connection to an Asterisk server Create one client for each ARI application
func ClientFromContext ¶
ClientFromContext returns the Client stored in the context with the default key
func ClientFromContextWithKey ¶
ClientFromContextWithKey returns the Client stored in the context with the given keyname
func NewClient ¶
NewClient creates a new Asterisk client This function does not attempt to connect to Asterisk itself. The ARI URL and websocket URL may also be defined by environment variables ARI_URL and ARI_WSURL, respectively; explicitly-supplied values for these in the supplied `Options` struct will override any environment variables. Defaults for each are to connect to `localhost` at the normal locations for each.
Additionally, username and password for the ARI connection may also be supplied by environment variables ARI_USERNAME and ARI_PASSWORD, respectively. There are no defaults for these values.
func (*Client) AddChannel ¶
func (c *Client) AddChannel(id string, req AddChannelRequest) error
AddChannel adds a channel to a bridge Equivalent to Post /bridges/{id}/addChannel
func (*Client) AnswerChannel ¶
Answer a channel Equivalent to Post /channels/{channelId}/answer
func (*Client) BridgeDelete ¶
BridgeDelete shuts down a bridge. If any channels are in this bridge, they will be removed and resume whatever they were doing beforehand. This means that the channels themselves are not deleted. Equivalent to DELETE /bridges/{id}
func (*Client) BridgeStopMoh ¶
BridgeStopMoh stops playing music on hold to a bridge. This will only stop music on hold being played via POST bridges/{id}/moh. Equivalent to DELETE /bridges/{id}/moh
func (*Client) ChangeDeviceState ¶
Change the state of a device controlled by ARI. (Note - implicitly creates the device state). Equivalent to PUT /deviceStates/{deviceName}
func (*Client) ChangeMailboxState ¶
Change the state of a mailbox. (Note - implicitly creates the mailbox). Equivalent to PUT /mailboxes/{mailboxName}
func (*Client) CheckDirection ¶
func (*Client) ContinueChannel ¶
func (c *Client) ContinueChannel(channelId string, req ContinueChannelRequest) error
Exit application and continue execution in the dialplan Equivalent to Post /channels/{channelId}/continue
func (*Client) ControlPlayback ¶
ControlPlayback allows the user to manipulate an in-process playback. TODO: list available operations. (Equivalent to POST /playbacks/{playbackID}/control)
func (*Client) CopyStoredRecording ¶
func (c *Client) CopyStoredRecording(recordingName string, destination string) (StoredRecording, error)
CopyStoredRecording copies a stored recording to a new destination within the stored recordings tree. Equivalent to Post /recordings/stored/{recordingName}/copy
func (*Client) CreateBridge ¶
func (c *Client) CreateBridge(req CreateBridgeRequest) (Bridge, error)
CreateBridge creates a new bridge Equivalent to POST /bridges
func (*Client) CreateChannel ¶
func (c *Client) CreateChannel(req OriginateRequest) (Channel, error)
CreateChannel originates a new call
func (*Client) CreateChannelWithId ¶
func (c *Client) CreateChannelWithId(id string, req OriginateRequest) (Channel, error)
CreateChannelWithId originates a new call with the given channel Id
func (*Client) CreateUserEvent ¶
func (c *Client) CreateUserEvent(eventName string, req CreateUserEventRequest) error
Generate a new user event Equivalent to Post /events/user/{eventName}
func (*Client) DeleteDeviceState ¶
Destroy a device-state controlled by ARI. Equivalent to DELETE /deviceStates/{deviceName}
func (*Client) DeleteMailbox ¶
Destroy a mailbox. Equivalent to DELETE /mailboxes/{mailboxName}
func (*Client) DeleteStoredRecording ¶
DeleteStoredRecording deletes a stored recording Equivalent to DELETE /recordings/stored/{recordingName}
func (*Client) GetApplication ¶
func (c *Client) GetApplication(applicationName string) (Application, error)
GetApplication returns the details of a given ARI application Equivalent to GET /applications/{applicationName}
func (*Client) GetAsteriskInfo ¶
func (c *Client) GetAsteriskInfo(only string) (*AsteriskInfo, error)
GetAsteriskInfo returns various data about the Asterisk system Equivalent to GET /asterisk/info
func (*Client) GetAsteriskVariable ¶
GetAsteriskVariable returns the value of the given global variable Equivalent to GET /asterisk/variable
func (*Client) GetBridge ¶
GetBridge returns the details of a bridge Equivalent to Get /bridges/{bridgeId}
func (*Client) GetChannel ¶
Get a specific channel's details Equivalent to Get /channels/{channelId}
func (*Client) GetChannelVariable ¶
Get the value of a channel variable or function Equivalent to Get /channels/{channelId}/variable
func (*Client) GetDeviceState ¶
func (c *Client) GetDeviceState(deviceName string) (DeviceState, error)
Retrieve the current state of a specified device Equivalent to GET /deviceStates/{deviceName}
func (*Client) GetEndpoint ¶
GetEndpoint requests the details of an endpoint from Asterisk
func (*Client) GetEndpointsByTech ¶
List available endpoints for a given endpoint technology Equivalent to Get /endpoints/{tech}
func (*Client) GetLiveRecording ¶
func (c *Client) GetLiveRecording(recordingName string) (*LiveRecording, error)
GetLiveRecording returns a specific live recording Equivalent to GET /recordings/live/{recordingName}
func (*Client) GetMailbox ¶
Retrieve the current state of a specific mailbox Equivalent to GET /mailboxes/{mailboxName}
func (*Client) GetPlaybackDetails ¶
GetPlaybackDetails returns a playback's details. (Equivalent to GET /playbacks/{playbackID})
func (*Client) GetStoredRecording ¶
func (c *Client) GetStoredRecording(recordingName string) (StoredRecording, error)
GetStoredRecording returns a stored recording's details Equivalent to GET /recordings/stored/{recordingName}
func (*Client) HangupChannel ¶
Delete (i.e. hangup) a channel. Equivalent to DELETE /channels/{channelId}
func (*Client) HoldChannel ¶
Hold a channel Equivalent to Post /channels/{channelId}/hold
func (*Client) ListApplications ¶
func (c *Client) ListApplications() ([]Application, error)
ListApplications returns the list of ARI applications on the Asterisk server Equivalent to GET /applications
func (*Client) ListBridges ¶
ListBridges returns all active bridges in Asterisk Equivalent to GET /bridges
func (*Client) ListChannels ¶
List all active channels in asterisk Equivalent to Get /channels
func (*Client) ListDeviceStates ¶
func (c *Client) ListDeviceStates() ([]DeviceState, error)
ListDeviceStates returns the list of all ARI controlled device states Equivalent to GET /deviceStates
func (*Client) ListEndpoints ¶
ListEndpoints lists all endpoints TODO: associated with the application, or on the entire system?
func (*Client) ListMailboxes ¶
List all mailboxes on asterisk server Equivalent to GET /mailboxes
func (*Client) ListSounds ¶
ListSounds returns a list of (all) the available sounds
func (*Client) ListSoundsFiltered ¶
ListSoundsFiltered lists sounds limited by the provided filters valid filters are "lang" and "format"
func (*Client) ListStoredRecordings ¶
func (c *Client) ListStoredRecordings() ([]StoredRecording, error)
ListStoredRecordings lists all completed recordings Equivalent to GET /recordings/stored
func (*Client) MuteChannel ¶
Mute a channel Equivalent to Post /channels/{channelId}/mute Viable options are "in," "out," or "both"
func (*Client) MuteLiveRecording ¶
MuteLiveRecording mutes a live recording Equivalent to Post /recordings/live/{recordingName}/mute
func (*Client) NewBridge ¶
NewBridge is a simple wrapper to create a new, unique bridge, with the default options
func (*Client) NewBridgeWithID ¶
NewBridgeWithID is a simple wrapper to create a new, unique bridge, with the default options
func (*Client) NewChannel ¶
func (c *Client) NewChannel(endpoint string, cid *CallerId, vars map[string]string) (Channel, error)
NewChannel is a shorthand for creating a new channel. It generates a unique Id, sets the destination to be the current application, and passes any variables through; pass nil for vars if no variables are needed
func (*Client) NewLocalChannel ¶
func (c *Client) NewLocalChannel(endpoint string, cid *CallerId, vars map[string]string) (Channel, Channel, error)
NewLocalChannel creates a new local channel and returns each side
func (*Client) NewOriginateRequest ¶
func (c *Client) NewOriginateRequest(endpoint string) OriginateRequest
NewOriginateRequest generates an originate request with a unique channel Id, destination equal to the current client, and an unlimited call timeout
func (*Client) PauseLiveRecording ¶
PauseLiveRecording pauses a live recording Equivalent to Post /recordings/live/{recordingName}/pause
func (*Client) PlayMOHToChannel ¶
Play music on hold to a channel Equivalent to Post /channels/{channelId}/moh
func (*Client) PlayMedia ¶
PlayMedia is a wrapper to initiate a playback with the given Media URI, returning the playback id
func (*Client) PlayMusicOnHold ¶
PlayMusicOnHold plays a music on hold class to a bridge or changes the existing MOH class Equivalent to Post /bridges/{bridgeId}/moh (music on hold)
func (*Client) PlaySilenceToChannel ¶
Play silence to a channel Equivalent to Post /channels/{channelId}/silence
func (*Client) PlayToBridge ¶
func (c *Client) PlayToBridge(id string, req PlayMediaRequest) (Playback, error)
PlayToBridge starts playback of media on specified bridge Equivalent to Post /bridges/{id}/play
func (*Client) PlayToBridgeByID ¶
func (c *Client) PlayToBridgeByID(id string, playbackID string, req PlayMediaRequest) (Playback, error)
PlayToBridgeByID starts playback of specific media on specified bridge Equivalent to Post /bridges/{id}/play/{playbackID}
func (*Client) PlayToChannel ¶
func (c *Client) PlayToChannel(channelId string, req PlayMediaRequest) (Playback, error)
Start playback of media to a channel Equivalent to Post /channels/{channelId}/play
func (*Client) PlayToChannelById ¶
func (c *Client) PlayToChannelById(channelId string, playbackId string, req PlayMediaRequest) (Playback, error)
Specifiy media to playback to a channel Equivalent to Post /channels/{channelId}/play/{playbackId}
func (*Client) RecordBridge ¶
func (c *Client) RecordBridge(id string, req *RecordRequest) (*LiveRecording, error)
RecordBridge starts a recording on specified bridge Equivalent to Post /bridges/{id}/record
func (*Client) RecordChannel ¶
func (c *Client) RecordChannel(channelId string, req *RecordRequest) (*LiveRecording, error)
Start a live recording Equivalent to Post /channels/{channelId}/record
func (*Client) ReloadModule ¶
ReloadModule tells asterisk to load the given module
func (*Client) RemoveChannel ¶
RemoveChannel removes the specified channel from a bridge Equivalent to Post /bridges/{id}/removeChannel
func (*Client) ResumeLiveRecording ¶
ResumeLiveRecording resumes (unpauses) a live recording Equivalent to DELETE /recordings/live/{recordingName}/pause
func (*Client) RingChannel ¶
Indicate ringing to a channel Equivalent to Post /channels/{channelId}/ring
func (*Client) ScrapLiveRecording ¶
ScrapLiveRecording stops a live recording and discard it Equivalent to DELETE /recordings/live/{recordingName} TODO reproduce this error in isolation: does not delete. Cannot delete any recording produced by this.
func (*Client) SendDTMFToChannel ¶
func (c *Client) SendDTMFToChannel(channelId string, req SendDTMFToChannelRequest) error
Send provided DTMF to a given channel Equivalent to Post /channels/{channelId}/dtmf
func (*Client) SendMessage ¶
SendMessage sends a text message to an endpoint
func (*Client) SendMessageByUri ¶
SendMessageByUri sends a text message to an endpoint by free-form URI (rather than tech/resource)
func (*Client) SetAsteriskVariable ¶
SetAsteriskVariable sets a global channel variable (Equivalent to POST /asterisk/variable)
func (*Client) SetChannelVariable ¶
Set the value of a variable Equivalent to Post /channels/{channelId}/variable
func (*Client) StartSnoopChannel ¶
func (c *Client) StartSnoopChannel(channelId string, req SnoopRequest) (Channel, error)
Start snooping Equivalent to Post /channels/{channelId}/snoop
func (*Client) StartSnoopChannelById ¶
func (c *Client) StartSnoopChannelById(channelId string, snoopId string, req SnoopRequest) (Channel, error)
Start Snooping by specific ID Equivalent to Post /channels/{channelId}/snoop/{snoopId}
func (*Client) StopHoldChannel ¶
Remove a channel from hold Equivalent to DELETE /channels/{channelId}/hold
func (*Client) StopLiveRecording ¶
StopLiveRecording stops and stores a live recording Equivalent to Post /recordings/live/{recordingName}/stop
func (*Client) StopMohChannel ¶
Stop playing music on hold to a channel Equivalent to DELETE /channels/{channelId}/moh
func (*Client) StopPlayback ¶
StopPlayback stops a playback session. (Equivalent to DELETE /playbacks/{playbackID})
func (*Client) StopRinging ¶
Stop ringing indication on a channel if locally generated. Equivalent to DELETE /channels/{channelId}/ring
func (*Client) StopSilenceChannel ¶
Stop playing silence to a channel Equivalent to DELETE /channels/{channelId}/silence
func (*Client) SubscribeApplication ¶
func (c *Client) SubscribeApplication(applicationName string, eventSource string) (Application, error)
SubscribeApplication subscribes the given application to an event source event source may be one of:
- channel:<channelId>
- bridge:<bridgeId>
- endpoint:<tech>/<resource> (e.g. SIP/102)
- deviceState:<deviceName>
Equivalent to POST /applications/{applicationName}/subscription
func (*Client) UnMuteChannel ¶
Unmute a channel Equivalent to DELETE /channels/{channelId}/mute
func (*Client) UnmuteLiveRecording ¶
UnmuteLiveRecording unmutes a live recording Equivalent to DELETE /recordings/live/{recordingName}/mute
func (*Client) UnsubscribeApplication ¶
func (c *Client) UnsubscribeApplication(applicationName string, eventSource string) (Application, error)
UnsubscribeApplication unsubscribes (removes a subscription to) a given ARI application from the provided event source Equivalent to DELETE /applications/{applicationName}/subscription
func (*Client) UpsertBridge ¶
func (c *Client) UpsertBridge(id string, req CreateBridgeRequest) (Bridge, error)
UpsertBridge adds or updates a bridge Equivalent to POST /bridges/{bridgeId}
type ConfigInfo ¶
type ConfigInfo struct { DefaultLanguage string `json:"default_language"` MaxChannels int `json:"max_channels,omitempty"` //omitempty denotes an optional field, meaning the field may not be present if no value is assigned. MaxLoad float64 `json:"max_load,omitempty"` MaxOpenFiles int `json:"max_open_files,omitempty"` Name string `json:"name"` // Asterisk system name SetID SetID `json:"setid"` // Effective user/group id under which Asterisk is running }
ConfigInfo describes information about the Asterisk configuration
type ContactInfo ¶
type ContactInfo struct { AOR string `json:"aor"` // Address of Record for this contact Status string `json:"contact_status"` // Current status of the contact Roundtrip string `json:"roundtrip_usec,omitempty"` // Current round trip time, in microseconds URI string `json:"uri"` // The location URI of the contact }
ContactInfo describes a Contact
func (*ContactInfo) Latency ¶
func (c *ContactInfo) Latency() time.Duration
Latency returns the round-trip time for this contact
type ContactStatusChanged ¶
type ContactStatusChanged struct { Event Endpoint Endpoint `json:"endpoint"` ContactInfo ContactInfo `json:"contact_info"` }
ContactStatusChanged events indicate that a contact state has changed
type ContinueChannelRequest ¶
type ContinueChannelRequest struct { Context string `json:"context,omitempty"` Extension string `json:"extension,omitempty"` Priority int64 `json:"priority,omitempty"` }
priority is of type long = int64 Request structure for ContinueChannel. All fields are optional. The three fields mirror the construction of a channel by Dialplan, as the function returns a channel to the dialplan.
type CreateBridgeRequest ¶
type CreateBridgeRequest struct { ID string `json:"bridgeId,omitempty"` Type string `json:"type,omitempty"` Name string `json:"name,omitempty"` }
CreateBridgeRequest is the structure for creating a bridge. No properies are required, meaning an empty struct may be passed to 'CreateBridge'
type CreateUserEventRequest ¶
type CreateUserEventRequest struct { Application string `json:"application"` Source string `json:"source,omitempty"` Variables string `json:"variables,omitempty"` }
Request structure for creating a user event. Only Application is required.
type DeviceState ¶
DeviceState describes the state of a device
type DeviceStateChanged ¶
type DeviceStateChanged struct { Event Device_state DeviceState `json:"device_state"` }
DeviceStateChanged events indicate that a device state has changed
type Dial ¶
type Dial struct { Event Caller Channel `json:"caller,omitempty"` // Dialing channel (if not system-originated) Dialstatus string `json:"dialstatus"` // Present status of the dial attempt Dialstring string `json:"dialstring,omitempty"` // The string describing the dial Forward string `json:"forward,omitempty"` // If present, indicates the forwarding target TODO: what is the format of this? Forwarded Channel `json:"forwarded,omitempty"` // If present, channel of forwarding target Peer Channel `json:"peer"` // Dialed channel }
Dial events indicate the dialing state for a channel has changed
type DialplanCEP ¶
type DialplanCEP struct { Context string `json:"context"` Exten string `json:"exten"` Priority int64 `json:"priority"` //int64 derived from Java's 'long' }
DialplanCEP describes a location in the dialplan (context,extension,priority)
type Endpoint ¶
type Endpoint struct { ChannelIds []string `json:"channel_ids"` // List of channel Ids which are associated with this endpoint Resource string `json:"resource"` // The endpoint's resource name State string `json:"state,omitempty"` // The state of the endpoint Technology string `json:"technology"` // The technology of the endpoint (e.g. SIP, PJSIP, DAHDI, etc) }
Endpoint describes an external device which may offer or accept calls to or from Asterisk. Devices are defined by a technology/resource pair.
Allowed states: 'unknown', 'offline', 'online'
type EndpointStateChange ¶
EndpointStateChange events indicate that an endpoint has changed state
type Event ¶
type Event struct { Message Application string `json:"application"` Timestamp AsteriskDate `json:"timestamp,omitempty"` }
Event is the base struct for all events
func (*Event) GetApplication ¶
type Eventer ¶
type Eventer interface { MessageRawer GetApplication() string GetType() string }
type FormatLangPair ¶
FormatLangPair describes the format and language of a sound file
type LiveRecording ¶
type LiveRecording struct { Cause string `json:"cause,omitempty"` // If failed, the cause of the failure DurationSec int `json:"duration,omitempty"` // Length of recording in seconds Format string `json:"format"` // Format of recording (wav, gsm, etc) Name string `json:"name"` // (base) name for the recording SilenceSec int `json:"silence_duration,omitempty"` // If silence was detected in the recording, the duration in seconds of that silence (requires that maxSilenceSeconds be non-zero) State string `json:"state"` // Current state of the recording TalkingSec int `json:"talking_duration,omitempty"` // Duration of talking, in seconds, that has been detected in the recording (requires that maxSilenceSeconds be non-zero) TargetURI string `json:"target_uri"` // URI for the channel or bridge which is being recorded (TODO: figure out format for this) // contains filtered or unexported fields }
LiveRecording describes a recording which is in progress
func Record ¶
func Record(ctx context.Context, r Recorder, name string, opts *RecordingOptions) (*LiveRecording, error)
Record starts a recording on the given Recorder.
func (*LiveRecording) Duration ¶
func (l *LiveRecording) Duration() (dur time.Duration)
Duration returns the duration of the live recording, if known
func (*LiveRecording) Resume ¶
func (l *LiveRecording) Resume() error
Resume unpauses the current LiveRecording
func (*LiveRecording) Scrap ¶
func (l *LiveRecording) Scrap() error
Scrap Stops and deletes the current LiveRecording TODO: reproduce this error in isolation: does not delete. Cannot delete any recording produced by this.
func (*LiveRecording) SilenceDuration ¶
func (l *LiveRecording) SilenceDuration() (dur time.Duration)
SilenceDuration returns the duration of the detected silence during the recording, if known
func (*LiveRecording) Status ¶
func (l *LiveRecording) Status() int
Status returns the status of the recording.
func (*LiveRecording) Stop ¶
func (l *LiveRecording) Stop() error
Stop and store current LiveRecording
func (*LiveRecording) TalkingDuration ¶
func (l *LiveRecording) TalkingDuration() (dur time.Duration)
TalkingDuration returns the duration of the detected talking during the recording, if known
type Mailbox ¶
type Mailbox struct { Name string `json:"name"` New_messages int `json:"new_messages"` // Number of new (unread) messages Old_messages int `json:"old_messages"` // Number of old (read) messages }
Mailbox respresents the state of an Asterisk (voice) mailbox
type Message ¶
type Message struct { RawMessage Type string `json:"type"` }
Message is the first extension of the RawMessage type, containing only a Type
func NewMessage ¶
Construct a Message from a byte slice
type MessageRawer ¶
type MissingParams ¶
type MissingParams struct { Message Params []string `json:"params"` // List of missing parameters which are required }
MissingParams is an error message response emitted when a request does not contain required parameters
type Options ¶
type Options struct { // Application is the the name of this ARI application Application string // URL is the root URL of the ARI server (asterisk box). // Default to http://localhost:8088/ari URL string // WebsocketURL is the URL for ARI Websocket events. // Defaults to the events directory of URL, with a protocol of ws. // Usually ws://localhost:8088/ari/events. WebsocketURL string // Username for ARI authentication Username string // Password for ARI authentication Password string }
Options describes client connection options
type OriginateRequest ¶
type OriginateRequest struct { Endpoint string `json:"endpoint"` // Endpoint to use (tech/resource notation) Timeout int `json:"timeout,omitempty"` // Dial Timeout in seconds (-1 = no limit) CallerId string `json:"callerId,omitempty"` // CallerId to set for outgoing call // One set of: Context string `json:"context,omitempty"` // Drop the channel into the dialplan Extension string `json:"extension,omitempty"` Priority int64 `json:"priority,omitempty"` // OR App string `json:"app,omitempty"` // Associate channel to Stasis (Ari) application AppArgs string `json:"appArgs,omitempty"` // Arguments to the application // Channel Id declarations ChannelId string `json:"channelId,omitempty"` // Optionally assign channel id OtherChannelId string `json:"otherChannelId,omitempty"` // Optionally assign second channel's id (only for local channels) Variables map[string]string `json:"variables,omitempty"` // Channel variables to set }
OriginateRequest is the basic structure for all channel creation methods
type Peer ¶
type Peer struct { Address string `json:"address,omitempty"` // IP Address of the peer Cause string `json:"cause,omitempty"` // Reason associated with change in peer_status Status string `json:"peer_status"` // The current state of the peer Port string `json:"port,omitempty"` // The port of the peer Time AsteriskDate `json:"time,omitempty"` // The last known time the peer was contacted }
Peer describes a remote peer that communicates with Asterisk
type PeerStatusChange ¶
PeerStatusChange events indicate that a peer has changed state
type PlayMediaRequest ¶
type Playback ¶
type Playback struct { ID string `json:"id"` // Unique ID for this playback session Language string `json:"language,omitempty"` MediaURI string `json:"media_uri"` // URI for the media which is to be played State string `json:"state"` // State of the playback operation TargetURI string `json:"target_uri"` // URI of the channel or bridge on which the media should be played (follows format of 'type':'name') // contains filtered or unexported fields }
Playback describes an ARI playback handle
type PlaybackFinished ¶
PlaybackFinished events indicate that a media playback operation has completed
type PlaybackOptions ¶
type PlaybackOptions struct { // ID is an optional ID to use for the playback's ID. If one // is not supplied, an ID will be randomly generated internally. // NOTE that this ID will only be used for the FIRST playback // in a queue. All subsequent playback IDs will be randomly generated. ID string // DTMF is an optional channel for received DTMF tones received during the playback. // This channel will NOT be closed by the playback. DTMF chan<- *ChannelDtmfReceived // ExitOnDTMF defines a list of DTMF digits on receipt of which will // terminate the playback of the queue. You may set this to AllDTMF // in order to match any DTMF digit. ExitOnDTMF string // Done is an optional channel for receiving notification when the playback // is complete. This is useful if the playback is to be executed asynchronously. // This channel will be closed by the playback when playback the is complete. Done chan<- struct{} }
PlaybackOptions describes various options which are available to playback operations.
type PlaybackQueue ¶
type PlaybackQueue struct {
// contains filtered or unexported fields
}
PlaybackQueue represents a sequence of audio playbacks which are to be played on the associated Player
func NewPlaybackQueue ¶
func NewPlaybackQueue() *PlaybackQueue
NewPlaybackQueue creates (but does not start) a new playback queue.
func (*PlaybackQueue) Add ¶
func (pq *PlaybackQueue) Add(mediaURIs ...string)
Add appends one or more mediaURIs to the playback queue
func (*PlaybackQueue) Flush ¶
func (pq *PlaybackQueue) Flush()
Flush empties a playback queue. NOTE that this does NOT stop the current playback.
func (*PlaybackQueue) Play ¶
func (pq *PlaybackQueue) Play(ctx context.Context, p Player, opts *PlaybackOptions) error
Play starts the playback of the queue to the Player.
func (*PlaybackQueue) PlayAsync ¶
func (pq *PlaybackQueue) PlayAsync(ctx context.Context, p Player, opts *PlaybackOptions) chan error
PlayAsync plays the queue, returing immediately with an error channel, which will pass any errors and be closed on completion of the queue.
func (*PlaybackQueue) ReceivedDTMF ¶
func (pq *PlaybackQueue) ReceivedDTMF() string
ReceivedDTMF returns any DTMF which has been received by the PlaybackQueue.
type PlaybackStarted ¶
PlaybackStarted events indicate that a media playback operation has begun
type PlayerRecorder ¶
type PlayerRecorder interface { Record(string, *RecordingOptions) (*LiveRecording, error) Play(string) (string, error) GetClient() *Client }
A PlayerRecorder is anywhich which can Record and Play
type RawMessage ¶
type RawMessage struct {
// contains filtered or unexported fields
}
func (*RawMessage) DecodeAs ¶
func (m *RawMessage) DecodeAs(v MessageRawer) error
DecodeAs converts the current message to a new message type
func (*RawMessage) GetRaw ¶
func (m *RawMessage) GetRaw() *[]byte
Get the __raw value of this RawMessage
func (*RawMessage) SetRaw ¶
func (m *RawMessage) SetRaw(raw *[]byte)
Set the __raw value of this RawMessage
type RecordRequest ¶
type RecordRequest struct { Name string `json:"name"` Format string `json:"format"` MaxDurationSeconds int `json:"maxDurationSeconds,omitempty"` MaxSilenceSeconds int `json:"maxSilenceSeconds,omitempty"` IfExists string `json:"ifExists,omitempty"` Beep bool `json:"beep,omitempty"` TerminateOn string `json:"terminateOn,omitempty"` }
type Recorder ¶
type Recorder interface { Record(string, *RecordingOptions) (*LiveRecording, error) GetClient() *Client }
A Recorder is anything which can "Record"
type RecordingFailed ¶
type RecordingFailed struct { Event Recording LiveRecording `json:"recording"` }
RecordingFailed events indicate that a recording operation request has failed to complete
type RecordingFinished ¶
type RecordingFinished struct { Event Recording LiveRecording `json:"recording"` }
RecordingFinished events indicate that a recording operation has completed
type RecordingOptions ¶
type RecordingOptions struct { // Format is the file format/encoding to which the recording should be stored. // This will usually be one of: slin, ulaw, alaw, wav, gsm. // If not specified, this will default to slin. Format string // MaxDuration is the maximum duration of the recording, after which the recording will // automatically stop. If not set, there is no maximum. MaxDuration time.Duration // MaxSilence is the maximum duration of detected to be found before terminating the recording. MaxSilence time.Duration // Exists determines what should happen if the given recording already exists. // Valid values are: "fail", "overwrite", or "append". // If not specified, it will default to "fail" Exists string // Beep indicates whether a beep should be played to the recorded // party at the beginning of the recording. Beep bool // Terminate indicates whether the recording should be terminated on // receipt of a DTMF digit. // valid options are: "none", "any", "*", and "#" // If not specified, it will default to "none" (never terminate on DTMF). Terminate string }
RecordingOptions describes the set of options available when making a recording.
func (*RecordingOptions) ToRequest ¶
func (o *RecordingOptions) ToRequest(name string) *RecordRequest
ToRequest converts a set of recording options to a record request.
type RecordingStarted ¶
type RecordingStarted struct { Event Recording LiveRecording `json:"recording"` }
RecordingStarted events indicate that a recording operation has begun
type RequestError ¶
RequestError describes an error with an error Code.
type SendDTMFToChannelRequest ¶
type SendDTMFToChannelRequest struct { Dtmf string `json:"dtmf,omitempty"` Before int `json:"before,omitempty"` Between int `json:"between,omitempty"` Duration int `json:"duration,omitempty"` After int `json:"after,omitempty"` }
SendDTMPFToChannel Request structure. All fields are optional.
type SetID ¶
type SetID struct { Group string `json:"group"` // group id (not name? why string?) User string `json:"user"` // user id (not name? why string?) }
SetID describes a userid/groupid pair
type SnoopRequest ¶
type SnoopRequest struct { Spy string `json:"spy,omitempty"` //Direction of audio to spy on, default is 'none' Whisper string `json:"whisper,omitempty"` //Direction of audio to whisper into, default is 'none' App string `json:"app"` //Application that the snooping channel is placed into AppArgs string `json:"appArgs,omitempty"` //The application arguments to pass to the Stasis application //Only necessary for 'StartSnoopChannel' SnoopId string `json:"snoopId,omitempty"` //Unique ID to assign to snooping channel }
Structure for snooping a channel. Only App is required.
type Sound ¶
type Sound struct { Formats []FormatLangPair `json:"formats"` Id string `json:"id"` Text string `json:"text,omitempty"` }
Sound describes a media file which may be played back
type StasisStart ¶
type StasisStart struct { Event Args []string `json:"args"` Channel Channel `json:"channel"` ReplaceChannel Channel `json:"replacechannel,omitempty"` // TODO: find out what this is }
StasisStart events indicate a channel has entered the Stasis (Ari) application
func (*StasisStart) GetChannel ¶
func (s *StasisStart) GetChannel(c *Client) Channel
GetChannel returns the channel for whom the StasisStart event occurred, optionally attaching a copy of the ARI client
type StatusInfo ¶
type StatusInfo struct { LastReloadTime AsteriskDate `json:"last_reload_time"` StartupTime AsteriskDate `json:"startup_time"` }
StatusInfo describes the state of an Asterisk system
type StoredRecording ¶
type StoredRecording struct { Format string `json:"format"` Name string `json:"name"` // contains filtered or unexported fields }
StoredRecording describes a past recording which may be played back (via GetStoredRecording)
func (*StoredRecording) Copy ¶
func (s *StoredRecording) Copy(destination string) (StoredRecording, error)
Copy current StoredRecording to a new name (retaining the existing copy)
type Subscription ¶
type Subscription struct { C chan Eventer // channel for sending events to the subscriber // contains filtered or unexported fields }
A Subscription is a wrapped channel for receiving events from the ARI event bus.
func (*Subscription) Cancel ¶
func (s *Subscription) Cancel()
Cancel cancels the subscription and removes it from the event bus.
func (*Subscription) Next ¶
func (s *Subscription) Next(ctx context.Context) Eventer
Next blocks for the next event in the subscription, returning that event when it arrives or nil if the subscription is canceled. Normally, one would listen to subscription.C directly, but this is a convenience function for providing a context to alternately cancel.
type SystemInfo ¶
SystemInfo describes information about the Asterisk system
type TextMessage ¶
type TextMessage struct { Body string `json:"body"` // The body (text) of the message From string `json:"from"` // Technology-specific source URI To string `json:"to"` // Technology-specific destination URI Variables []TextMessageVariable `json:"variables,omitempty"` }
TextMessage describes text message
type TextMessageReceived ¶
type TextMessageReceived struct { Event Endpoint Endpoint `json:"endpoint,omitempty"` Message TextMessage `json:"message"` }
TextMessageReceived events indicate that an endpoint has emitted a text message
type TextMessageVariable ¶
TextMessageVariable describes a key-value pair (associated with a text message)