(id uuid.UUID, conn net.Conn)
| 62 | } |
| 63 | |
| 64 | func NewSessionFromStream(id uuid.UUID, conn net.Conn) (*Session, error) { |
| 65 | ctx, cancel := context.WithCancel(context.Background()) |
| 66 | r := &Session{ |
| 67 | ID: id, |
| 68 | Conn: conn, |
| 69 | Context: ctx, |
| 70 | cancelFunc: cancel, |
| 71 | Buf: bytes.Buffer{}, |
| 72 | Open: true, |
| 73 | } |
| 74 | err := addSession(r) |
| 75 | if err != nil { |
| 76 | return nil, err |
| 77 | } |
| 78 | return r, nil |
| 79 | } |
| 80 | |
| 81 | func addSession(r *Session) error { |
| 82 | if _, ok := GetSession(r.ID); ok { |
no test coverage detected