Skip to content

Commit

Permalink
Added Move method to channels (#155)
Browse files Browse the repository at this point in the history
* Added Move method to channels
  • Loading branch information
Naapperas authored Sep 4, 2023
1 parent 1961bc3 commit 2b7d4e3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ type Channel interface {
// Continue tells Asterisk to return a channel to the dialplan
Continue(key *Key, context, extension string, priority int) error

// Move moves the channel into another Stasis application
Move(key *Key, app string, appArgs string) error

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

Expand Down Expand Up @@ -326,6 +329,11 @@ func (ch *ChannelHandle) Continue(context, extension string, priority int) error
return ch.c.Continue(ch.key, context, extension, priority)
}

// Move moves the channel to a new Stasis app
func (ch *ChannelHandle) Move(app string, appArgs string) error {
return ch.c.Move(ch.key, app, appArgs)
}

//---
// Play/Record operations
//---
Expand Down
13 changes: 13 additions & 0 deletions client/native/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,19 @@ func (c *Channel) Continue(key *ari.Key, context, extension string, priority int
return c.client.post("/channels/"+key.ID+"/continue", nil, &req)
}

// Move moves the channel to another stasis application
func (c *Channel) Move(key *ari.Key, app string, appArgs string) error {
req := struct {
App string `json:"app"`
AppArgs string `json:"appArgs"`
}{
App: app,
AppArgs: appArgs,
}

return c.client.post("/channels/"+key.ID+"/move", nil, &req)
}

// Busy sends the busy status code to the channel (TODO: does this play a busy signal too)
func (c *Channel) Busy(key *ari.Key) error {
return c.Hangup(key, "busy")
Expand Down

0 comments on commit 2b7d4e3

Please sign in to comment.