public MainViewModel()
        {
            _serializationService = new CobsSerializationService();
            _serializationService.RegisterType <MessageHandShakeRequest>(0);
            _serializationService.RegisterType <MessageAcknowledgment>(1);
            _serializationService.RegisterType <MessageAddSession>(2);
            _serializationService.RegisterType <MessageRemoveSession>(3);
            _serializationService.RegisterType <MessageUpdateVolumeSession>(4);
            _serializationService.RegisterType <MessageSetDefaultEndpoint>(5);
            _serializationService.RegisterType <MessageSettings>(6);

            _settingsViewModel = new SettingsViewModel();
            _settingsViewModel.PropertyChanged += OnSettingsChanged;

            _audioSessionService = new AudioSessionService();
            _audioSessionService.DefaultDeviceChanged += OnDefaultDeviceChanged;
            _audioSessionService.DeviceCreated        += OnDeviceCreated;
            _audioSessionService.DeviceRemoved        += OnDeviceRemoved;
            _audioSessionService.DeviceVolumeChanged  += OnDeviceVolumeChanged;
            _audioSessionService.SessionCreated       += OnAudioSessionCreated;
            _audioSessionService.SessionRemoved       += OnAudioSessionRemoved;
            _audioSessionService.SessionVolumeChanged += OnAudioSessionVolumeChanged;

            _communicationService = new CommunicationService(_serializationService);
            _communicationService.MessageReceived  += OnMessageReceived;
            _communicationService.Error            += OnCommunicationError;
            _communicationService.DeviceDiscovered += OnDeviceDiscovered;
        }
Beispiel #2
0
        public MainViewModel()
        {
            _serializationService = new CobsSerializationService();
            _serializationService.RegisterType <MessageHandShakeRequest>(0);
            _serializationService.RegisterType <MessageHandShakeResponse>(1);
            _serializationService.RegisterType <MessageAddSession>(2);
            _serializationService.RegisterType <MessageRemoveSession>(3);
            _serializationService.RegisterType <MessageUpdateVolumeSession>(4);
            _serializationService.RegisterType <MessageSettings>(5);

            _settingsViewModel = new SettingsViewModel();
            _settingsViewModel.PropertyChanged += OnSettingsChanged;

            // TODO: pass in SystemSounds
            _audioSessionService = new AudioSessionService(_settingsViewModel.SystemSounds);
            _audioSessionService.SessionCreated       += OnAudioSessionCreated;
            _audioSessionService.SessionRemoved       += OnAudioSessionRemoved;
            _audioSessionService.SessionVolumeChanged += OnAudioSessionVolumeChanged;

            _discoveryService = new DiscoveryService(_serializationService);
            _discoveryService.DeviceDiscovered += OnDeviceDiscovered;

            _communicationService = new CommunicationService(_serializationService);
            _communicationService.MessageReceived += OnMessageReceived;
            _communicationService.Error           += OnCommunicationError;
        }