예제 #1
0
        /// <summary>
        /// Gets the LoginSession object for the provided accountId, creating one if necessary
        /// </summary>
        /// <param name="accountId">the AccountId</param>
        /// <returns>the login session for that accountId</returns>
        /// <exception cref="ArgumentNullException">thrown when accountId is null or empty</exception>
        /// <remarks>If a new LoginSession is created, LoginSessions.AfterKeyAdded will be raised.</remarks>
        public ILoginSession GetLoginSession(AccountId accountId)
        {
            if (AccountId.IsNullOrEmpty(accountId))
            {
                throw new ArgumentNullException(nameof(accountId));
            }

            CheckInitialized();
            if (_loginSessions.ContainsKey(accountId))
            {
                return(_loginSessions[accountId]);
            }
            var loginSession = new LoginSession(this, accountId);

            _loginSessions[accountId]     = loginSession;
            loginSession.PropertyChanged += delegate(object sender, PropertyChangedEventArgs args)
            {
                if (args.PropertyName != nameof(loginSession.State))
                {
                    return;
                }
                if (loginSession.State == LoginState.LoggedOut)
                {
                    _loginSessions.Remove(accountId);
                }
            };
            return(loginSession);
        }
예제 #2
0
        public IChannelSession GetChannelSession(ChannelId channelId)
        {
            if (ChannelId.IsNullOrEmpty(channelId))
            {
                throw new ArgumentNullException(nameof(channelId));
            }
            AssertLoggedIn();
            if (_channelSessions.ContainsKey(channelId))
            {
                return(_channelSessions[channelId]);
            }
            var c = new ChannelSession(this, channelId, _groupHandle);

            _channelSessions[channelId] = c;
            return(c);
        }
예제 #3
0
        public void UpdateLocation(string uriWithTag, PresenceStatus status, string message)
        {
            PresenceLocation item;

            if (!_locations.ContainsKey(uriWithTag))
            {
                if (status != PresenceStatus.Unavailable)
                {
                    item = new PresenceLocation(uriWithTag)
                    {
                        CurrentPresence = new Presence(status, message),
                        Subscription    = this
                    };
                    _locations[item.Key] = item;
                }
            }
            else
            {
                item = (PresenceLocation)_locations[uriWithTag];
                item.CurrentPresence = new Presence(status, message);
                if (status == PresenceStatus.Unavailable)
                {
                    _locations.Remove(uriWithTag);
                }
            }
        }
예제 #4
0
        private void HandleBuddyPresenceEvt(vx_evt_base_t eventMessage)
        {
            vx_evt_buddy_presence_t evt = eventMessage;

            if (evt.account_handle != _accountHandle)
            {
                return;
            }

            var buddyAccount = new AccountId(evt.buddy_uri, evt.displayname);

            if (!_presenceSubscriptions.ContainsKey(buddyAccount))
            {
                return;
            }

            var subscription = (PresenceSubscription)_presenceSubscriptions[buddyAccount];

            subscription.UpdateLocation(evt.buddy_uri, (PresenceStatus)evt.presence,
                                        evt.custom_message);
        }
        private void HandleParticipantUpdated(vx_evt_base_t eventMessage)
        {
            vx_evt_participant_updated_t evt = eventMessage;

            Debug.Assert(evt != null);
            if (evt.session_handle != _sessionHandle)
            {
                return;
            }
            if (_participants.ContainsKey(evt.participant_uri))
            {
                ChannelParticipant p = _participants[evt.participant_uri] as ChannelParticipant;
                Debug.Assert(p != null);
                p.IsMutedForAll             = evt.is_moderator_muted != 0;
                p.SpeechDetected            = evt.is_speaking != 0;
                p.InAudio                   = (evt.active_media & 0x1) == 0x1;
                p.InText                    = (evt.active_media & 0x2) == 0x2;
                p.AudioEnergy               = evt.energy;
                p._internalVolumeAdjustment = evt.volume;
                p._internalMute             = evt.is_muted_for_me != 0;
            }
        }