(conn net.Conn)
| 45 | } |
| 46 | |
| 47 | func NewSession(conn net.Conn) (*Session, error) { |
| 48 | ctx, cancel := context.WithCancel(context.Background()) |
| 49 | r := &Session{ |
| 50 | ID: uuid.New(), |
| 51 | Conn: conn, |
| 52 | Context: ctx, |
| 53 | cancelFunc: cancel, |
| 54 | Buf: bytes.Buffer{}, |
| 55 | Open: true, |
| 56 | } |
| 57 | err := addSession(r) |
| 58 | if err != nil { |
| 59 | return nil, err |
| 60 | } |
| 61 | return r, nil |
| 62 | } |
| 63 | |
| 64 | func NewSessionFromStream(id uuid.UUID, conn net.Conn) (*Session, error) { |
| 65 | ctx, cancel := context.WithCancel(context.Background()) |
no test coverage detected