New creates a new instance of WebTTY. masterConn is a connection to the PTY master, typically it's a websocket connection to a client. slave is a PTY slave such as a local command with a PTY.
(masterConn Master, slave Slave, options ...Option)
| 41 | // typically it's a websocket connection to a client. |
| 42 | // slave is a PTY slave such as a local command with a PTY. |
| 43 | func New(masterConn Master, slave Slave, options ...Option) (*WebTTY, error) { |
| 44 | wt := &WebTTY{ |
| 45 | masterConn: masterConn, |
| 46 | slave: slave, |
| 47 | |
| 48 | permitWrite: false, |
| 49 | columns: 0, |
| 50 | rows: 0, |
| 51 | |
| 52 | bufferSize: MaxBufferSize, |
| 53 | lastPingTime: time.Now(), |
| 54 | } |
| 55 | |
| 56 | for _, option := range options { |
| 57 | option(wt) |
| 58 | } |
| 59 | |
| 60 | return wt, nil |
| 61 | } |
| 62 | |
| 63 | // Run starts the main process of the WebTTY. |
| 64 | // This method blocks until the context is canceled. |
no outgoing calls