Files
goSam/accept.go

40 lines
621 B
Go
Raw Normal View History

2014-02-12 22:14:19 +01:00
package goSam
import (
"fmt"
"net"
2015-03-25 21:37:41 +01: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) {
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
}
fmt.Println("destination:", c.destination)
2014-02-12 22:14:19 +01:00
c, err = c.NewClient()
2014-02-12 22:14:19 +01:00
if err != nil {
return nil, err
}
if c.debug {
c.SamConn = debug.WrapConn(c.SamConn)
2014-02-12 22:14:19 +01: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)
return c.SamConn, nil
2014-02-12 22:14:19 +01:00
}