예제 #1
0
        public Task UpdateAsync(LoggingContext logginContext, string displayName, bool isEnableFilter)
        {
            Uri bridgeUri = UriHelper.CreateAbsoluteUri(this.BaseUri, this.PlatformResource.SelfUri);

            var input = new BridgedParticipantInput()
            {
                DisplayName        = displayName,
                MessageFilterState = isEnableFilter ? FilterState.Enabled : FilterState.Disabled,
                Uri = this.PlatformResource.Uri
            };

            //Waiting for bridgedParticipant operation added
            return(this.PutRelatedPlatformResourceAsync(bridgeUri, input, new ResourceJsonMediaTypeFormatter(), logginContext));
        }
예제 #2
0
        /// <summary>
        /// Add bridged participant
        /// </summary>
        /// <param name="logginContext"></param>
        /// <param name="displayName"></param>
        /// <param name="sipUri"></param>
        /// <param name="enableMessageFilter"></param>
        /// <returns>the bridgeParticipant added</returns>
        public async Task <IBridgedParticipant> AddBridgedParticipantAsync(LoggingContext logginContext, string displayName, string sipUri, bool enableMessageFilter)
        {
            if (string.IsNullOrWhiteSpace(sipUri) || sipUri.IndexOf('@') < 0)
            {
                throw new ArgumentException(nameof(sipUri));
            }

            string href = PlatformResource?.BridgedParticipantsResourceLink?.Href;

            if (string.IsNullOrWhiteSpace(href))
            {
                throw new CapabilityNotAvailableException("Link to get BridgedsParticipants is not available.");
            }

            Uri bridgeUri = UriHelper.CreateAbsoluteUri(this.BaseUri, href);

            var input = new BridgedParticipantInput()
            {
                DisplayName        = displayName,
                MessageFilterState = enableMessageFilter ? FilterState.Enabled : FilterState.Disabled,
                Uri = sipUri
            };

            TaskCompletionSource <BridgedParticipant> tcs = new TaskCompletionSource <BridgedParticipant>();

            m_bridgedParticipantTcses.TryAdd(sipUri.ToLower(), tcs);
            //Waiting for bridgedParticipant operation added
            await PostRelatedPlatformResourceAsync(bridgeUri, input, new ResourceJsonMediaTypeFormatter(), logginContext).ConfigureAwait(false);

            BridgedParticipant result = null;

            try
            {
                result = await tcs.Task.TimeoutAfterAsync(WaitForEvents).ConfigureAwait(false);
            }
            catch (TimeoutException)
            {
                throw new RemotePlatformServiceException("Timeout to get bridged participant added from platformservice!");
            }

            if (result == null)
            {
                throw new RemotePlatformServiceException("Platformservice do not deliver a bridged participant added resource with uri " + sipUri);
            }

            return(result);
        }