예제 #1
0
        public IAsyncResult BeginRefresh(AsyncCallback callback)
        {
            AsyncNoResult result  = new AsyncNoResult(callback);
            var           request = new vx_req_aux_get_render_devices_t();

            _client.BeginIssueRequest(request, ar =>
            {
                vx_resp_aux_get_render_devices_t response;
                try
                {
                    response = _client.EndIssueRequest(ar);
                    _devices.Clear();
                    for (var i = 0; i < response.count; ++i)
                    {
                        var device   = VivoxCoreInstance.get_device(i, response.render_devices);
                        var id       = device.device;
                        var name     = device.display_name;
                        _devices[id] = new AudioDevice {
                            Key = id, Name = name
                        };
                    }

                    _systemDevice = new AudioDevice
                    {
                        Key  = response.default_render_device.device,
                        Name = response.default_render_device.display_name
                    };
                    _communicationDevice = new AudioDevice
                    {
                        Key  = response.default_communication_render_device.device,
                        Name = response.default_communication_render_device.display_name
                    };
                    var effectiveDevice = new AudioDevice
                    {
                        Key  = response.effective_render_device.device,
                        Name = response.effective_render_device.display_name,
                    };
                    if (!effectiveDevice.Equals(_effectiveDevice))
                    {
                        // Only fire the event if the effective device has truly changed.
                        _effectiveDevice = effectiveDevice;
                        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(EffectiveDevice)));
                    }
                    result.SetComplete();
                }
                catch (Exception e)
                {
                    VivoxDebug.Instance.VxExceptionMessage($"{request.GetType().Name} failed: {e}");
                    result.SetComplete(e);
                    if (VivoxDebug.Instance.throwInternalExcepetions)
                    {
                        throw;
                    }
                    return;
                }
            });
            return(result);
        }
예제 #2
0
 /// <summary>
 /// Uninitialize this Client instance.
 /// If this Client instance is not initialized, it will do nothing.
 /// </summary>
 public void Uninitialize()
 {
     if (_initialized)
     {
         VxClient.Instance.Stop();
         _inputDevices.Clear();
         _outputDevices.Clear();
         _loginSessions.Clear();
         _initialized     = false;
         _connectorHandle = null;
     }
 }
예제 #3
0
 private void Cleanup()
 {
     _channelSessions.Clear();
     _transmittingChannel = null;
     _presenceSubscriptions.Clear();
     _allowedSubscriptions.Clear();
     _blockedSubscriptions.Clear();
     _incomingSubscriptionRequests.Clear();
     _directedMessages.Clear();
     _failedDirectedMessages.Clear();
     _accountArchive.Clear();
     VxClient.Instance.EventMessageReceived -= Instance_EventMessageReceived;
 }
예제 #4
0
        private void HandleSessionRemoved(vx_evt_base_t eventMessage)
        {
            vx_evt_session_removed_t evt = eventMessage;

            Debug.Assert(evt != null);
            if (evt.session_handle != _sessionHandle)
            {
                return;
            }
            AudioState = ConnectionState.Disconnected;
            TextState  = ConnectionState.Disconnected;
            _participants.Clear();
            _typing = false;
            _messageLog.Clear();
        }
예제 #5
0
 public void Logout()
 {
     if (_state == LoginState.LoggedIn || _state == LoginState.LoggingIn)
     {
         var request = new vx_req_account_logout_t();
         request.account_handle = _accountHandle;
         VxClient.Instance.BeginIssueRequest(request, null);
         _presenceSubscriptions.Clear();
         _allowedSubscriptions.Clear();
         _blockedSubscriptions.Clear();
         _channelSessions.Clear();
         _directedMessages.Clear();
         _failedDirectedMessages.Clear();
         _incomingSubscriptionRequests.Clear();
         _transmittingSession = null;
         VxClient.Instance.EventMessageReceived -= Instance_EventMessageReceived;
         // Specifically do not change the property in a way that raises an event
         _state = LoginState.LoggedOut;
     }
 }