pyatv
pyatv copied to clipboard
Feat/fire and forget remote
This pull request introduces several reliability and usability improvements to the MRP protocol implementation, focusing on robust connection handling, improved command sending flexibility, and enhanced compatibility with sandboxed network environments. It also adds new tests to ensure correct behavior in these areas.
MRP Protocol Reliability and Command Handling:
- Added robust connection checks and error handling in
sendandsend_rawmethods ofMrpConnection, raisingConnectionLostErrorif the connection is closed or lost during send operations. [1] [2] - Refactored
MrpProtocolto centralize connection state checks with_ensure_send_possible, ensuring proper exceptions are raised for invalid or closed states. Enhancedsendandsend_and_receiveto handle fire-and-forget (no response) operations and propagate connection errors. [1] [2] [3] - Updated internal
_send_commandand publicsend_commandinMrpRemoteControlto support fire-and-forget commands and custom timeouts, improving API flexibility. [1] [2] [3]
Network Compatibility Improvements:
- Improved multicast socket setup and private address detection to work on sandboxed platforms (e.g., iOS, Docker) by probing the default IPv4 address as a fallback when no adapters are reported. [1] [2]
Testing Enhancements:
- Added tests for fire-and-forget command sending, connection loss handling, and the new fallback network behaviors to ensure correctness and reliability. [1] [2] [3] [4]