(messageParts ...MessagePart)
| 377 | } |
| 378 | |
| 379 | func (c *PTYConversation) Send(messageParts ...MessagePart) error { |
| 380 | // Validate message content before enqueueing |
| 381 | message := buildStringFromMessageParts(messageParts) |
| 382 | if message != msgfmt.TrimWhitespace(message) { |
| 383 | return ErrMessageValidationWhitespace |
| 384 | } |
| 385 | if message == "" { |
| 386 | return ErrMessageValidationEmpty |
| 387 | } |
| 388 | |
| 389 | c.lock.Lock() |
| 390 | if c.statusLocked() != ConversationStatusStable { |
| 391 | c.lock.Unlock() |
| 392 | return ErrMessageValidationChanging |
| 393 | } |
| 394 | c.lock.Unlock() |
| 395 | |
| 396 | errCh := make(chan error, 1) |
| 397 | c.outboundQueue <- outboundMessage{parts: messageParts, errCh: errCh} |
| 398 | return <-errCh |
| 399 | } |
| 400 | |
| 401 | // sendMessage sends a message to the agent. It acquires and releases c.lock |
| 402 | // around the parts that access shared state, but releases it during |
nothing calls this directly
no test coverage detected