channel

package
v0.0.0-...-2ec00d9 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallerInfo

type CallerInfo struct {
	Name   string `json:"name"`
	Number string `json:"number"`
}

type Channel

type Channel interface {
	// Get returns a handle to a channel for further interaction
	Get(key *key.Key) *ChannelHandle

	// GetVariable retrieves the value of a channel variable
	GetVariable(*key.Key, string) (string, error)

	// List lists the channels in asterisk, optionally using the key for filtering
	List(*key.Key) ([]*key.Key, error)

	// Originate creates a new channel, returning a handle to it or an error, if
	// the creation failed.
	// The Key should be that of the linked channel, if one exists, so that the
	// Node can be matches to it.
	Originate(*key.Key, requests.OriginateRequest) (*ChannelHandle, error)

	// Create creates a new channel, returning a handle to it or an
	// error, if the creation failed. Create is already Staged via `Dial`.
	// The Key should be that of the linked channel, if one exists, so that the
	// Node can be matches to it.
	Create(*key.Key, requests.ChannelCreateRequest) (*ChannelHandle, error)

	// Data returns the channel data for a given channel
	Data(key *key.Key) (*ChannelData, error)

	// Continue tells Asterisk to return a channel to the dialplan
	Continue(key *key.Key, context, extension string, priority int) error

	// Busy hangs up the channel with the "busy" cause code
	Busy(key *key.Key) error

	// Congestion hangs up the channel with the "congestion" cause code
	Congestion(key *key.Key) error

	// Answer answers the channel
	Answer(key *key.Key) error

	// Hangup hangs up the given channel
	Hangup(key *key.Key, reason string) error

	// Ring indicates ringing to the channel
	Ring(key *key.Key) error

	// StopRing stops ringing on the channel
	StopRing(key *key.Key) error

	// SendDTMF sends DTMF to the channel
	SendDTMF(key *key.Key, dtmf string, opts *arioptions.DTMFOptions) error

	// Hold puts the channel on hold
	Hold(key *key.Key) error

	// StopHold retrieves the channel from hold
	StopHold(key *key.Key) error

	// Mute mutes a channel in the given direction (in,out,both)
	Mute(key *key.Key, dir arioptions.Direction) error

	// Unmute unmutes a channel in the given direction (in,out,both)
	Unmute(key *key.Key, dir arioptions.Direction) error

	// MOH plays music on hold
	MOH(key *key.Key, moh string) error

	// SetVariable sets a channel variable
	SetVariable(key *key.Key, name, value string) error

	// StopMOH stops music on hold
	StopMOH(key *key.Key) error

	// Silence plays silence to the channel
	Silence(key *key.Key) error

	// StopSilence stops the silence on the channel
	StopSilence(key *key.Key) error

	// Play plays the media URI to the channel
	Play(key *key.Key, playbackID string, mediaURI string) (*play.PlaybackHandle, error)

	// Record records the channel
	Record(key *key.Key, name string, opts *arioptions.RecordingOptions) (*recordings.LiveRecordingHandle, error)

	// Dial dials a created channel
	Dial(key *key.Key, caller string, timeout time.Duration) error

	// Snoop spies on a specific channel, creating a new snooping channel
	Snoop(key *key.Key, snoopID string, opts *arioptions.SnoopOptions) (*ChannelHandle, error)

	// StageExternalMedia creates a new non-telephony external media channel,
	// when `Exec`ed, by which audio may be sent or received.  The stage version
	// of this command will not actually communicate with Asterisk until Exec is
	// called on the returned ExternalMedia channel.
	StageExternalMedia(key *key.Key, opts arioptions.ExternalMediaOptions) (*ChannelHandle, error)

	// ExternalMedia creates a new non-telephony external media channel by which audio may be sent or received
	ExternalMedia(key *key.Key, opts arioptions.ExternalMediaOptions) (*ChannelHandle, error)
}

type ChannelData

type ChannelData struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	State        string `json:"state"`
	Protocol     string `json:"protocol"`
	Caller       CallerInfo
	Connected    CallerInfo
	Accountcode  string `json:"accountcode"`
	Dialplan     DialplanInfo
	Creationtime string            `json:"creationtime"`
	Language     string            `json:"language"`
	ChannelVars  map[string]string `json:"channelvars"`
}

func (*ChannelData) GetID

func (c *ChannelData) GetID() string

type ChannelHandle

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

ChannelHandle provides a wrapper on the Channel interface for operations on a particular channel ID.

func NewChannelHandle

func NewChannelHandle(key *key.Key, c Channel, exec func(ch *ChannelHandle) error) *ChannelHandle

NewChannelHandle returns a handle to the given ARI channel

func (*ChannelHandle) Answer

func (ch *ChannelHandle) Answer() error

Answer answers the channel

func (*ChannelHandle) Busy

func (ch *ChannelHandle) Busy() error

Busy hangs up the channel with the "busy" cause code

func (*ChannelHandle) Congestion

func (ch *ChannelHandle) Congestion() error

Congestion hangs up the channel with the congestion cause code

func (*ChannelHandle) Continue

func (ch *ChannelHandle) Continue(context, extension string, priority int) error

Continue tells Asterisk to return the channel to the dialplan

func (*ChannelHandle) Create

Create creates (but does not dial) a new channel, using the present channel as its Originator.

func (*ChannelHandle) Data

func (ch *ChannelHandle) Data(key *key.Key) (*ChannelData, error)

Data returns the channel's data

func (*ChannelHandle) Dial

func (ch *ChannelHandle) Dial(caller string, timeout time.Duration) error

Dial dials a created channel. `caller` is the optional channel ID of the calling party (if there is one). Timeout is the length of time to wait before the dial is answered before aborting.

func (*ChannelHandle) Exec

func (ch *ChannelHandle) Exec() (err error)

Exec executes any staged channel operations attached to this handle.

func (*ChannelHandle) ExternalMedia

func (ch *ChannelHandle) ExternalMedia(opts arioptions.ExternalMediaOptions) (*ChannelHandle, error)

ExternalMedia creates a new non-telephony external media channel by which audio may be sent or received

func (*ChannelHandle) GetVariable

func (ch *ChannelHandle) GetVariable(name string) (string, error)

GetVariable returns the value of a channel variable

func (*ChannelHandle) Hangup

func (ch *ChannelHandle) Hangup() error

Hangup hangs up the channel with the normal cause code

func (*ChannelHandle) Hold

func (ch *ChannelHandle) Hold() error

Hold puts the channel on hold

func (*ChannelHandle) ID

func (ch *ChannelHandle) ID() string

func (*ChannelHandle) IsAnswered

func (ch *ChannelHandle) IsAnswered() (bool, error)

IsAnswered checks the current state of the channel to see if it is "Up"

func (*ChannelHandle) Key

func (ch *ChannelHandle) Key() *key.Key

Key returns the key for the channel handle

func (*ChannelHandle) List

func (ch *ChannelHandle) List(key *key.Key) ([]*key.Key, error)

func (*ChannelHandle) MOH

func (ch *ChannelHandle) MOH(mohClass string) error

MOH plays music on hold of the given class to the channel

func (*ChannelHandle) Mute

func (ch *ChannelHandle) Mute(dir arioptions.Direction) (err error)

Mute mutes the channel in the given direction (in, out, both)

func (*ChannelHandle) Originate

Originate creates (and dials) a new channel using the present channel as its Originator.

func (*ChannelHandle) Play

func (ch *ChannelHandle) Play(id string, mediaURI string) (ph *play.PlaybackHandle, err error)

Play initiates playback of the specified media uri to the channel, returning the Playback handle

func (*ChannelHandle) Record

Record records the channel to the given filename

func (*ChannelHandle) Ring

func (ch *ChannelHandle) Ring() error

StopRing stops ringing on the channel

func (*ChannelHandle) SendDTMF

func (ch *ChannelHandle) SendDTMF(dtmf string, opts *arioptions.DTMFOptions) error

SendDTMF sends the DTMF information to the server

func (*ChannelHandle) SetVariable

func (ch *ChannelHandle) SetVariable(name, value string) error

SetVariable sets the value of a channel variable

func (*ChannelHandle) Silence

func (ch *ChannelHandle) Silence() error

Silence plays silence to the channel

func (*ChannelHandle) Snoop

func (ch *ChannelHandle) Snoop(snoopID string, opts *arioptions.SnoopOptions) (*ChannelHandle, error)

Snoop spies on a specific channel, creating a new snooping channel placed into the given app

func (*ChannelHandle) StageExternalMedia

func (ch *ChannelHandle) StageExternalMedia(opts arioptions.ExternalMediaOptions) (*ChannelHandle, error)

StageExternalMedia creates a new non-telephony external media channel, when `Exec`ed, by which audio may be sent or received. The stage version of this command will not actually communicate with Asterisk until Exec is called on the returned ExternalMedia channel.

func (*ChannelHandle) StageOriginate

func (ch *ChannelHandle) StageOriginate(req arioptions.OriginateRequest) (*ChannelHandle, error)

StageOriginate stages an originate (channel creation and dial) to be Executed later.

func (*ChannelHandle) StageSnoop

func (ch *ChannelHandle) StageSnoop(snoopID string, opts *arioptions.SnoopOptions) (*ChannelHandle, error)

StageSnoop stages a `Snoop` operation

func (*ChannelHandle) StopHold

func (ch *ChannelHandle) StopHold() error

StopHold retrieves the channel from hold

func (*ChannelHandle) StopMOH

func (ch *ChannelHandle) StopMOH() error

StopMOH stops playing of music on hold to the channel

func (*ChannelHandle) StopRing

func (ch *ChannelHandle) StopRing() error

Ring indicates ringing to the channel

func (*ChannelHandle) StopSilence

func (ch *ChannelHandle) StopSilence() error

StopSilence stops silence to the channel

func (*ChannelHandle) Unmute

func (ch *ChannelHandle) Unmute(dir arioptions.Direction) (err error)

Unmute unmutes the channel in the given direction (in, out, both)

type DialplanInfo

type DialplanInfo struct {
	Context  string `json:"context"`
	Exten    string `json:"exten"`
	Priority int    `json:"priority"`
	AppName  string `json:"app_name"`
	AppData  string `json:"app_data"`
}

Jump to

Keyboard shortcuts

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