2024-11-13 14:39:08 -05:00
|
|
|
package gosam
|
2014-02-10 21:01:55 +01:00
|
|
|
|
2014-02-14 12:05:13 +01:00
|
|
|
// StreamConnect asks SAM for a TCP-Like connection to dest, has to be called on a new Client
|
2021-04-15 17:21:41 -04:00
|
|
|
func (c *Client) StreamConnect(dest string) error {
|
2020-11-29 16:09:55 -05:00
|
|
|
if dest == "" {
|
2020-11-29 16:23:55 -05:00
|
|
|
return nil
|
2020-11-29 16:09:55 -05:00
|
|
|
}
|
2021-04-15 17:21:41 -04:00
|
|
|
r, err := c.sendCmd("STREAM CONNECT ID=%s DESTINATION=%s %s %s\n", c.ID(), dest, c.from(), c.to())
|
2014-02-10 21:01:55 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2025-03-07 01:35:21 +00:00
|
|
|
if !r.IsOk() {
|
|
|
|
return ReplyError{r.GetResult(), r}
|
2014-02-10 21:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2014-02-12 22:14:19 +01:00
|
|
|
|
2014-02-14 12:05:13 +01:00
|
|
|
// StreamAccept asks SAM to accept a TCP-Like connection
|
2021-04-15 17:21:41 -04:00
|
|
|
func (c *Client) StreamAccept() (*Reply, error) {
|
|
|
|
r, err := c.sendCmd("STREAM ACCEPT ID=%s SILENT=false\n", c.ID())
|
2014-02-12 22:14:19 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2025-03-07 01:35:21 +00:00
|
|
|
if !r.IsOk() {
|
|
|
|
return nil, ReplyError{r.GetResult(), r}
|
2014-02-12 22:14:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return r, nil
|
|
|
|
}
|