How unitree-czk/capacitor-udp works
Main Components
a) Plugin Layer:
• Capacitor Plugin Interface (top level)
• Platform-specific implementations:
• iOS Implementation (Swift/Objective-C)
• Android Implementation (Java)
• Web Implementation (TypeScript)
b) Core UDP Components:
• Socket Management System
• Data Transport Layer
• Event System
[Application Layer]
• ↕
[Capacitor UDP Plugin Interface]
• ↕
┌──────────────────────────────────┐
• Platform-Specific Implementations │
• ┬──────────┬─────────┤
• iOS UDP │ Android │ Web │
• Plugin │ UDP │ UDP │
• Plugin │ Plugin │
• ┴──────────┴─────────┘
• ↕
[Native UDP Socket Layer]
Key Components to Highlight
a) Socket Management:
• Create/Close operations
• Socket state management
• Multiple socket support
b) Data Operations:
• Send/Receive mechanisms
• Buffer management
• Broadcast/Multicast support
c) Event System:
• Receive events
• Error handling
• State changes
Special Features to Emphasize
• IPv4/IPv6 support
• Multicast capabilities
• Broadcast functionality
• Buffer conversion utilities
Implementation Details
[Socket Operations]
• Create
• Bind
• Send
• Receive
• Close
[Multicast Operations]
• Join Group
• Leave Group
• Get Joined Groups
[Configuration]
• Set Broadcast
• Set Paused
• Set Multicast Loopback
Data Flow Representation
Following flows:
• Application → Plugin Interface → Native Implementation → UDP Socket
• UDP Socket → Native Implementation → Event System → Application
Important Notes
• A note about buffer conversion between ArrayBuffer and String
• Event-driven nature of the receive operations
• Relationship between the plugin and Capacitor's core system
• Multi-socket capability