2014-02-12 22:14:19 +01:00
|
|
|
package goSam
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net"
|
2015-03-25 21:37:41 +01:00
|
|
|
|
2019-02-28 14:22:28 -05:00
|
|
|
"github.com/eyedeekay/gosam/debug"
|
2014-02-12 22:14:19 +01:00
|
|
|
)
|
|
|
|
|
2014-02-14 12:05:13 +01:00
|
|
|
// Accept creates a new Client and accepts a connection on it
|
2014-02-12 22:14:19 +01:00
|
|
|
func (c *Client) Accept() (net.Conn, error) {
|
2019-02-27 20:25:36 -05:00
|
|
|
var err error
|
|
|
|
var id int32
|
|
|
|
id = c.NewID()
|
|
|
|
c.destination, err = c.CreateStreamSession(id, "")
|
2014-02-12 22:14:19 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-02-27 20:25:36 -05:00
|
|
|
fmt.Println("destination:", c.destination)
|
2014-02-12 22:14:19 +01:00
|
|
|
|
2019-02-27 20:25:36 -05:00
|
|
|
c, err = c.NewClient()
|
2014-02-12 22:14:19 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2018-07-16 02:49:03 -04:00
|
|
|
if c.debug {
|
2019-02-27 20:25:36 -05:00
|
|
|
c.SamConn = debug.WrapConn(c.SamConn)
|
2014-02-12 22:14:19 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 20:25:36 -05:00
|
|
|
resp, err := c.StreamAccept(id)
|
2014-02-12 22:14:19 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println("Accept Resp:", resp)
|
|
|
|
|
2019-02-27 20:25:36 -05:00
|
|
|
return c.SamConn, nil
|
2014-02-12 22:14:19 +01:00
|
|
|
}
|