Open Sound Control (OSC)
weswecan
NativePHP^3iOS15.0+Android21+PHP^8.2
Send and receive OSC messages over UDP on iOS and Android — for show control, audio, lighting, Arduino, and ESP32 workflows.
Features
- UDP-based OSC messaging (no TCP)
- Multiple simultaneous listeners with distinct IDs
- Typed argument support:
int,float,string,blob - Bundle transmission support
- Local network address discovery
- Foreground-first lifecycle (listeners auto-stop when app backgrounds)
- Event-driven PHP and JavaScript architecture
Installation
Requires a license from nativephp.com/plugins.
composer config repositories.nativephp-plugins composer https://plugins.nativephp.com
composer config http-basic.plugins.nativephp.com your@email.com your-license-key
composer require weswecan/nativephp-mobile-osc
php artisan native:plugin:register weswecan/nativephp-mobile-osc
PHP Usage
use Weswecan\Osc\Facades\Osc;
// Get local IP address
$address = Osc::getLocalAddress();
// Start listening on port 8000
Osc::listen(id: 'main', port: 8000);
// Send a message
Osc::send(
host: '192.168.1.100',
port: 9000,
address: '/volume',
arguments: [['type' => 'float', 'value' => 0.75]],
);
// Send a bundle
Osc::sendBundle(
host: '192.168.1.100',
port: 9000,
timetag: 0,
messages: [
['address' => '/play', 'arguments' => []],
['address' => '/volume', 'arguments' => [['type' => 'float', 'value' => 1.0]]],
]
);
// Stop a listener
Osc::stop(id: 'main');
Livewire Usage
use Native\Mobile\Attributes\OnNative;
use Weswecan\Osc\Events\OscMessageReceived;
#[OnNative(OscMessageReceived::class)]
public function onMessage(string $listenerId, string $address, array $arguments): void
{
// Handle incoming message
}
Compatibility
| Platform | Minimum Version |
|---|---|
| NativePHP | ^3 |
| iOS | 15.0+ |
| Android | API 21+ |
| PHP | ^8.2 |
Events
OscMessageReceived— incoming message;listenerId,address,argumentsOscBundleReceived— incoming bundle;listenerId,timetag,messagesOscListenerStarted— listener active;listenerId,portOscListenerStopped— listener stopped;listenerIdOscMessageSent— send confirmed;host,port,addressOscError— error during send or receive;listenerId,error