onInputSourcesChange method

void onInputSourcesChange(
  1. dynamic event
)

Implementation

void onInputSourcesChange( event ) {

  final inputSources = session.inputSources;

  // Assign inputSources to available controllers

  for (int i = 0; i < controllers.length; i ++ ) {
    inputSourcesMap[inputSources[ i ]] =  controllers[ i ];
  }

  // Notify disconnected

  for (int i = 0; i < event.removed.length; i ++ ) {
    final inputSource = event.removed[ i ];
    final controller = inputSourcesMap[inputSource];

    if ( controller ) {
      controller.dispatchEvent(Event(type: 'disconnected', data: inputSource));
      inputSourcesMap.remove( inputSource );
    }
  }

  // Notify connected

  for (int i = 0; i < event.added.length; i ++ ) {
    final inputSource = event.added[ i ];
    final controller = inputSourcesMap[inputSource];

    if ( controller ) {
      controller.dispatchEvent( Event(type: 'connected', data: inputSource));
    }
  }
}