Optionaloptions: CecAdapterOptionsAdds the listener function to the end of the listeners array for the
event named eventName. No checks are made to see if the listener has
already been added. Multiple calls passing the same combination of eventName
and listener will result in the listener being added, and called, multiple
times.
server.on('connection', (stream) => {
console.log('someone connected!');
});
Returns a reference to the EventEmitter, so that calls can be chained.
By default, event listeners are invoked in the order they are added. The
emitter.prependListener() method can be used as an alternative to add the
event listener to the beginning of the listeners array.
import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.on('foo', () => console.log('a'));
myEE.prependListener('foo', () => console.log('b'));
myEE.emit('foo');
// Prints:
// b
// a
The callback function
Adds a one-time listener function for the event named eventName. The
next time eventName is triggered, this listener is removed and then invoked.
server.once('connection', (stream) => {
console.log('Ah, we have our first user!');
});
Returns a reference to the EventEmitter, so that calls can be chained.
By default, event listeners are invoked in the order they are added. The
emitter.prependOnceListener() method can be used as an alternative to add the
event listener to the beginning of the listeners array.
import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.once('foo', () => console.log('a'));
myEE.prependOnceListener('foo', () => console.log('b'));
myEE.emit('foo');
// Prints:
// b
// a
The callback function
Alias for emitter.removeListener().
Open a connection to the adapter at port. Returns true on success.
Optionalport: stringOptionaltimeout: numberClose the connection and stop libCEC's worker thread.
Power on the given device (default: broadcast).
Optionaladdress: CecLogicalAddressPut the given device into standby (default: broadcast).
Optionaladdress: CecLogicalAddressBecome the active source, presenting as deviceType.
OptionaldeviceType: CecDeviceTypeMark this device as no longer the active source.
Raise the volume on the audio system. Returns the new volume (0–100, 0xFF unknown).
OptionalsendRelease: booleanLower the volume on the audio system. Returns the new volume.
OptionalsendRelease: booleanToggle mute on the audio system. Returns the new volume.
OptionalsendRelease: booleanSend a remote-key press to destination.
Optionalwait: booleanSend a remote-key release to destination.
Optionalwait: booleanShow message on destination's OSD for duration.
Logical address of the current active source.
Vendor id of the device (see vendorIdToString).
Logical addresses of all active devices on the bus.
Logical addresses this adapter has claimed.
Enable/disable passive monitoring mode.
Set the stream path to a physical address (routes the source).
Set the stream path to a device by logical address.
Re-scan the bus for active devices.
Ping all connected adapters.
Enumerate the connected CEC adapters.
libCEC build/version information.
An open (or openable) connection to a CEC adapter.
CecAdapteris an EventEmitter: libCEC fires its callbacks from its own worker thread and the addon marshals each onto the Node event loop, so listeners run on the main thread like any other event. Always call CecAdapter.close when finished.