WaitReady blocks up to timeout for the initial agent handshake. Returns ErrAgentTimeout if nothing arrives, or the request context error if cancelled.
(ctx context.Context, timeout time.Duration)
| 323 | // WaitReady blocks up to timeout for the initial agent handshake. Returns |
| 324 | // ErrAgentTimeout if nothing arrives, or the request context error if cancelled. |
| 325 | func (s *Session) WaitReady(ctx context.Context, timeout time.Duration) (AgentResult, error) { |
| 326 | timer := time.NewTimer(timeout) |
| 327 | defer timer.Stop() |
| 328 | select { |
| 329 | case r := <-s.agentReady: |
| 330 | return r, nil |
| 331 | case <-timer.C: |
| 332 | return AgentResult{}, ErrAgentTimeout |
| 333 | case <-ctx.Done(): |
| 334 | return AgentResult{}, ctx.Err() |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | // OnAgentConnected is called when the agent sends rdp_proxy_connected. |
| 339 | // Signals the handshake channel so ServeCreateTicket can proceed. |