public IActionResult Update([FromBody] Models.Invitation invitation) { IActionResult result = null; IMapper mapper = null; IInvitation innerInvitation = null; if (result == null && invitation == null) { result = BadRequest("Missing invitation data"); } if (result == null && (!invitation.InvitationId.HasValue || invitation.InvitationId.Equals(Guid.Empty))) { result = BadRequest("Missing id"); } if (result == null && !invitation.EventDate.HasValue) { result = BadRequest("Missing event date"); } if (result == null && !invitation.RSVPDueDate.HasValue) { result = BadRequest("Missing RSVP date"); } if (result == null && string.IsNullOrEmpty(invitation.Title)) { result = BadRequest("Missing title"); } if (result == null && string.IsNullOrEmpty(invitation.Invitee)) { result = BadRequest("Missing invitee"); } if (result == null) { mapper = new Mapper(m_mapperConfiguration); using (ILifetimeScope scope = m_container.BeginLifetimeScope()) { IInvitationFactory factory = scope.Resolve <IInvitationFactory>(); innerInvitation = factory.Get(m_settings.Value, invitation.InvitationId.Value); if (innerInvitation == null) { result = NotFound(); } else { mapper.Map <Models.Invitation, IInvitation>(invitation, innerInvitation); IInvitationSaver saver = scope.Resolve <IInvitationSaver>(); saver.Update(m_settings.Value, innerInvitation); invitation = mapper.Map <Models.Invitation>(innerInvitation); result = Ok(invitation); } } } return(result); }
public IActionResult Get(Guid id) { IActionResult result = null; if (result == null && id.Equals(Guid.Empty)) { result = BadRequest("Missing id"); } if (result == null) { using (ILifetimeScope scope = m_container.BeginLifetimeScope()) { IInvitationFactory factory = scope.Resolve <IInvitationFactory>(); IInvitation invitation = factory.Get(m_settings.Value, id); if (invitation == null) { result = NotFound(); } else { IMapper mapper = new Mapper(m_mapperConfiguration); result = Ok(mapper.Map <Models.Invitation>(invitation)); } } } return(result); }
/// <summary> /// add invitation record to invitation manager /// </summary> /// <param name="InitiatorId">who invites</param> /// <param name="RecipientId">who is invited</param> /// <returns>is invitation successful</returns> public bool AddInvitation <T>(string InitiatorId, string RecipientId) where T : IInvitation { //если(я.id == ты.id && я.кого == ты.кого || я.id == ты.кого && я.кого == ты.id) lock (Invitations) { IInvitation Il = this.Invitations.OfType <T>().Where(x => x.InitiatorId == InitiatorId && x.RecipientId == RecipientId || x.InitiatorId == RecipientId && x.RecipientId == InitiatorId).SingleOrDefault(); if (Il != null) { if (Il.Status == GameInvitation.StatusRejected) { int role = this.GetRole <T>(InitiatorId, RecipientId); if (role == GameInvitation.RoleRecipient) { this.RemoveInvitation <T>(RecipientId, InitiatorId); AddInvitation <T>(InitiatorId, RecipientId); return(true); } } return(false); } else { T ni = (T)Activator.CreateInstance(typeof(T), new object[] { InitiatorId, RecipientId }); Invitations.Add(ni); return(true); } } }
/* * CALLBACKS SECTION. This section shows how we implement the several games * API callbacks. */ public void OnConnected(Bundle connectionHint) { Log.Debug(TAG, "onConnected() called. Sign in successful!"); Log.Debug(TAG, "Sign-in succeeded."); // register listener so we are notified if we receive an invitation to play // while we are in the game GamesClass.Invitations.RegisterInvitationListener(mGoogleApiClient, this); if (connectionHint != null) { Log.Debug(TAG, "onConnected: connection hint ed. Checking for e."); IInvitation inv = (IInvitation)connectionHint .GetParcelable(Multiplayer.ExtraInvitation); if (inv != null && inv.InvitationId != null) { // retrieve and cache the invitation ID Log.Debug(TAG, "onConnected: connection hint has a room invite!"); AcceptInviteToRoom(inv.InvitationId); return; } } SwitchToMainScreen(); }
public InviteController( IInvitation invitation, ILogger <InviteController> logger ) { Invitation = invitation; Logger = logger; }
public void CreateInvitationShould() { Guid testGuid = Guid.NewGuid(); IInvitation invitation = _invitationFactory.CreateInvitation(testGuid, "*****@*****.**"); Assert.Equal(testGuid, invitation.Id); Assert.Equal("*****@*****.**", invitation.Email); }
public bool RemoveInvitation(IInvitation inviteItem) { if (!(inviteItem is Invitation inviteGen)) { throw new ArgumentNullException("inviteItem"); } return(Add(inviteGen)); }
public InvitationViewModel(IInvitation invitation) { InvitationId = invitation.InvitationId; UserIdReceiver = invitation.UserIdReceiver; UserIdSender = invitation.UserIdSender; Date = invitation.Date; AccountId = invitation.AccountId; }
public bool AddInvitation(IInvitation inviteItem, ICustomer customer) { if (!(inviteItem is Invitation inviteGen)) { throw new ArgumentNullException("inviteItem"); } return(Add(inviteGen)); }
public InvitationResponse(InvitationResponseData responseData, IInvitationResponseDataSaver responseDataSaver, IInvitation invitation) { m_responseData = responseData; m_responseDataSaver = responseDataSaver; m_invitation = invitation; }
private void HandleInvitationEvent <T>(EventContext eventcontext, Func <T, IInvitation> inviteGenerateDelegate) where T : InvitationResource { string NormalizedUri = UriHelper.NormalizeUriWithNoQueryParameters(eventcontext.EventEntity.Link.Href, eventcontext.BaseUri); T localResource = this.ConvertToPlatformServiceResource <T>(eventcontext); IInvitation invite = m_invites.GetOrAdd(localResource.OperationContext, (a) => { Logger.Instance.Information(string.Format("[Communication] Started and Add invitation: OperationContext:{0}, Href: {1} , LoggingContext: {2}", localResource.OperationContext, NormalizedUri, eventcontext.LoggingContext == null ? string.Empty : eventcontext.LoggingContext.ToString())); return(inviteGenerateDelegate(localResource)); }); if (invite.RelatedConversation == null) { //Populate conversation resource if needed string relatedConversationNormalizedUri = UriHelper.NormalizeUriWithNoQueryParameters(localResource.ConversationResourceLink.Href, eventcontext.BaseUri); Uri relatedConversationUri = UriHelper.CreateAbsoluteUri(eventcontext.BaseUri, localResource.ConversationResourceLink.Href); Conversation relatedConversation = m_conversations.GetOrAdd(relatedConversationNormalizedUri, (a) => { Logger.Instance.Information(string.Format("[Communication] Add conversation {0} LoggingContext: {1}", relatedConversationNormalizedUri, eventcontext.LoggingContext == null ? string.Empty : eventcontext.LoggingContext.ToString())); return(new Conversation(this.RestfulClient, null, eventcontext.BaseUri, relatedConversationUri, this)); } ); ((IInvitationWithConversation)invite).SetRelatedConversation(relatedConversation); } //Remove from cache if it is a complete operation if (eventcontext.EventEntity.Relationship == EventOperation.Completed) { IInvitation completedInvite = null; Logger.Instance.Information(string.Format("[Communication] Completed and remove invitation: OperationContext:{0}, Href: {1} , LoggingContext: {2}", localResource.OperationContext, NormalizedUri, eventcontext.LoggingContext == null ? string.Empty : eventcontext.LoggingContext.ToString())); m_invites.TryRemove(localResource.OperationContext, out completedInvite); } var eventableEntity = invite as EventableEntity; eventableEntity.HandleResourceEvent(eventcontext); if (eventcontext.EventEntity.Relationship == EventOperation.Started) //here we ignore the case that a new incoming invite is failure and with completed operation { var temp = eventcontext.EventEntity.EmbeddedResource as InvitationResource; if (temp.Direction == Direction.Incoming) { var application = this.Parent as Application; var applications = application.Parent as Applications; var discover = applications.Parent as Discover; var endpoint = discover.Parent as ApplicationEndpoint; endpoint.HandleNewIncomingInvite(invite); //TODO:should we treat new incoming INVITE (with new conversation) differently than the incoming modality escalation invite? } } }
/// <summary> /// schedule and trusted join a adhoc meeting /// </summary> /// <param name="subject">the meeting subject</param> /// <param name="callbackContext">the call back context</param> /// <param name="loggingContext">the logging context</param> /// <returns></returns> internal async Task <IOnlineMeetingInvitation> StartMeetingAsync(string subject, string callbackContext, LoggingContext loggingContext = null) { string href = PlatformResource?.StartAdhocMeetingLink?.Href; if (string.IsNullOrWhiteSpace(href)) { throw new CapabilityNotAvailableException("Link start adhoc meeting in not available."); } Logger.Instance.Information(string.Format("[AudioVideoInvitation] calling StartAdhocMeetingAsync. LoggingContext:{0}", loggingContext == null ? string.Empty : loggingContext.ToString())); var communication = this.Parent as Communication; string operationId = Guid.NewGuid().ToString(); var tcs = new TaskCompletionSource <IInvitation>(); //Adding current invitation to collection for tracking purpose. communication.HandleNewInviteOperationKickedOff(operationId, tcs); string callbackUrl = null; var application = communication.Parent as Application; application.GetCallbackUrlAndCallbackContext(ref callbackUrl, ref callbackContext); IInvitation invite = null; var input = new StartAdhocMeetingInput { Subject = subject, CallbackContext = callbackContext, CallbackUrl = callbackUrl, OperationContext = operationId }; var adhocMeetingUri = UriHelper.CreateAbsoluteUri(this.BaseUri, href); await this.PostRelatedPlatformResourceAsync(adhocMeetingUri, input, new ResourceJsonMediaTypeFormatter(), loggingContext).ConfigureAwait(false); Task completed = await Task.WhenAny(Task.Delay(WaitForEvents), tcs.Task).ConfigureAwait(false); if (completed != tcs.Task) { throw new RemotePlatformServiceException("Timeout to get Onlinemeeting Invitation started event from platformservice!"); } else { invite = await tcs.Task.ConfigureAwait(false);// Incase need to throw exception } //We are sure the invite sure be there now. OnlineMeetingInvitation result = invite as OnlineMeetingInvitation; if (result == null) { throw new RemotePlatformServiceException("Platformservice do not deliver a Onlinemeeting resource with operationId " + operationId); } return(result); }
public IEnumerable <IInvitationResponse> GetByInvitation(ISettings settings, IInvitation invitation) { using (ILifetimeScope scope = m_dependencyContainer.GetContainer().BeginLifetimeScope()) { IInvitationResponseDataFactory dataFactory = scope.Resolve <IInvitationResponseDataFactory>(); IInvitationResponseDataSaver dataSaver = scope.Resolve <IInvitationResponseDataSaver>(); return(dataFactory.GetByInvitationId(new Settings(settings), invitation.InvitationId) .Select <InvitationResponseData, IInvitationResponse>(d => new InvitationResponse(d, dataSaver, invitation))); } }
/// <summary> /// Saas application Joins the adhoc meeting as trusted entity, won't be seen by other conference participants /// </summary> /// <param name="loggingContext"><see cref="LoggingContext"/> to be used for logging all related events</param> /// <param name="callbackContext">A state/context object which will be provided by SfB in all related events</param> /// <returns><see cref="IOnlineMeetingInvitation"/> which can be used to wait for the meeting join to complete</returns> internal async Task <IOnlineMeetingInvitation> JoinAdhocMeetingAsync(string callbackContext, LoggingContext loggingContext = null) { string href = PlatformResource?.JoinAdhocMeetingLink?.Href; if (string.IsNullOrWhiteSpace(href)) { throw new CapabilityNotAvailableException("Link to join adhoc meeting is not available."); } string callbackUrl = null; (Parent as Application).GetCallbackUrlAndCallbackContext(ref callbackUrl, ref callbackContext); var joinMeetingInput = new JoinMeetingInvitationInput() { CallbackContext = callbackContext, OperationContext = Guid.NewGuid().ToString(), CallbackUrl = callbackUrl }; var communication = (Parent as Application).Communication as Communication; IInvitation invite = null; //Adding current invitation to collection for tracking purpose. var tcs = new TaskCompletionSource <IInvitation>(); communication.HandleNewInviteOperationKickedOff(joinMeetingInput.OperationContext, tcs); Logger.Instance.Information("Joining adhoc meeting " + href); var adhocMeetingUri = UriHelper.CreateAbsoluteUri(BaseUri, href); await PostRelatedPlatformResourceAsync(adhocMeetingUri, joinMeetingInput, new ResourceJsonMediaTypeFormatter(), loggingContext).ConfigureAwait(false); Task finishedTask = await Task.WhenAny(Task.Delay(WaitForEvents), tcs.Task).ConfigureAwait(false); if (finishedTask != tcs.Task) { throw new RemotePlatformServiceException("Timeout to get OnlinemeetingInvitation started event from platformservice"); } else { invite = await tcs.Task.ConfigureAwait(false); // Incase need to throw exception } // We know for sure that the invitation is there now. var result = invite as IOnlineMeetingInvitation; if (result == null) { throw new RemotePlatformServiceException("Platformservice did not deliver a OnlinemeetingInvitation resource with operationId " + joinMeetingInput.OperationContext); } return(result); }
// Called when we get an invitation to play a game. We react by showing that to the user. public void OnInvitationReceived(IInvitation invitation) { // We got an invitation to play a game! So, store it in // mIncomingInvitationId // and show the popup on the screen. mIncomingInvitationId = invitation.InvitationId; var textView = (TextView)FindViewById(Resource.Id.incoming_invitation_text); textView.SetText(invitation.Inviter.DisplayName + " " + GetString(Resource.String.is_inviting_you), TextView.BufferType.Normal); SwitchToScreen(mCurScreen); // This will show the invitation popup }
/// <summary> /// удаляет приглашение когда оно принято. дальше за это отвечает база данных /// </summary> /// <param name="InitiatorId"></param> /// <param name="RecipientId"></param> public void RemoveInvitation <T>(string InitiatorId, string RecipientId) where T : IInvitation { lock (Invitations) { IInvitation Il = this.Invitations.OfType <T>().Where(x => x.InitiatorId == InitiatorId && x.RecipientId == RecipientId).SingleOrDefault(); if (Il != null) { Invitations.Remove(Il); } } }
public void AcceptInvitation <T>(string InitiatorId, string RecipientId) where T : IInvitation { lock (Invitations) { IInvitation Il = this.Invitations.OfType <T>().Where(x => x.InitiatorId == InitiatorId && x.RecipientId == RecipientId).SingleOrDefault(); if (Il != null) { Il.Status = GameInvitation.StatusAccepted; } } }
/// <summary> /// Handle a invitation complete event /// </summary> /// <param name="operationId"></param> /// <param name="exception"></param> internal void HandleInviteStarted(string operationId, IInvitation invite) { TaskCompletionSource <IInvitation> tcs = null; m_inviteAddedTcses.TryGetValue(operationId, out tcs); if (tcs != null) { tcs.TrySetResult(invite); TaskCompletionSource <IInvitation> removeTemp = null; m_inviteAddedTcses.TryRemove(operationId, out removeTemp); } }
public bool IsInvitationRejected <T>(String InitiatorId, String RecipientId) where T : IInvitation { IInvitation Il = this.Invitations.OfType <T>().Where(x => x.InitiatorId == InitiatorId && x.RecipientId == RecipientId).SingleOrDefault(); if (Il != null && Il.Status == GameInvitation.StatusRejected) { return(true); } else { return(false); } }
public IInvitationResponse Create(IInvitation invitation, bool?isAttending, short?attendingCount, string note) { using (ILifetimeScope scope = m_dependencyContainer.GetContainer().BeginLifetimeScope()) { InvitationResponseData responseData = new InvitationResponseData() { IsAttending = isAttending, AttendeeCount = attendingCount, Note = note }; return(new InvitationResponse(responseData, scope.Resolve <IInvitationResponseDataSaver>(), invitation)); } }
public void CreateInvite(IInvitation invitation) { using (var connection = _connection.SqlConnection) { var command = new SqlCommand("INSERT INTO dbo.Invitations (UserIdSender,UserIdReceiver,[Date],AccountId) VALUES (@Sender,@Receiver,@Date,@AccountId)", connection); command.Parameters.AddWithValue("@AccountId", invitation.AccountId); command.Parameters.AddWithValue("@Receiver", invitation.UserIdReceiver); command.Parameters.AddWithValue("@Sender", invitation.UserIdSender); command.Parameters.AddWithValue("@Date", invitation.Date); connection.Open(); command.ExecuteNonQuery(); connection.Close(); } }
// Handle the result of the invitation inbox UI, where the player can pick an invitation // to accept. We react by accepting the selected invitation, if any. private void HandleInvitationInboxResult(Result response, Intent data) { if (response != Result.Ok) { Log.Warn(TAG, "*** invitation inbox UI cancelled, " + response); SwitchToMainScreen(); return; } Log.Debug(TAG, "Invitation inbox UI succeeded."); IInvitation inv = (IInvitation)data.Extras.GetParcelable(Multiplayer.ExtraInvitation); // accept invitation AcceptInviteToRoom(inv.InvitationId); }
/// <summary> /// Handle new incoming invite /// </summary> internal void HandleNewIncomingInvite(IInvitation newInvite) { var messagingInvite = newInvite as IMessagingInvitation; if (messagingInvite != null) { handleIncomingInstantMessagingCall?.Invoke(this, new IncomingInviteEventArgs <IMessagingInvitation>(messagingInvite)); } var audioVideoInvite = newInvite as IAudioVideoInvitation; if (audioVideoInvite != null) { handleIncomingAudioVideoCall?.Invoke(this, new IncomingInviteEventArgs <IAudioVideoInvitation>(audioVideoInvite)); } }
/// <summary> /// add participant as an asynchronous operation. /// </summary> /// <param name="targetSip">The target sip.</param> /// <param name="loggingContext">The logging context.</param> /// <returns>Task<IParticipantInvitation>.</returns> /// <exception cref="CapabilityNotAvailableException">Link to add participant is not available.</exception> /// <exception cref="RemotePlatformServiceException"> /// Timeout to get Participant invitation started event from platformservice! /// or /// Platformservice do not deliver a ParticipantInvitation resource with operationId " + operationId /// </exception> public async Task <IParticipantInvitation> AddParticipantAsync(SipUri targetSip, LoggingContext loggingContext = null) { string href = PlatformResource?.AddParticipantResourceLink?.Href; if (string.IsNullOrEmpty(href)) { throw new CapabilityNotAvailableException("Link to add participant is not available."); } var communication = this.Parent as Communication; IInvitation invite = null; string operationId = Guid.NewGuid().ToString(); TaskCompletionSource <IInvitation> tcs = new TaskCompletionSource <IInvitation>(); communication.HandleNewInviteOperationKickedOff(operationId, tcs); var input = new AddParticipantInvitationInput { OperationContext = operationId, To = targetSip.ToString() }; Uri addparticipantUrl = UriHelper.CreateAbsoluteUri(this.BaseUri, href); await this.PostRelatedPlatformResourceAsync(addparticipantUrl, input, new ResourceJsonMediaTypeFormatter(), loggingContext).ConfigureAwait(false); try { invite = await tcs.Task.TimeoutAfterAsync(WaitForEvents).ConfigureAwait(false); } catch (TimeoutException) { throw new RemotePlatformServiceException("Timeout to get Participant invitation started event from platformservice!"); } var result = invite as ParticipantInvitation; if (result == null) { throw new RemotePlatformServiceException("Platformservice do not deliver a ParticipantInvitation resource with operationId " + operationId); } return(result); }
/// <summary> /// определяет кто инициатор а кто акцептор приглашения по порядку следования полей в базе /// </summary> /// <param name="InitiatorId"></param> /// <param name="RecipientId"></param> /// <returns></returns> public int GetRole <T>(String InitiatorId, String RecipientId) where T : IInvitation { IInvitation Il = this.Invitations.OfType <T>().Where(x => x.InitiatorId == InitiatorId && x.RecipientId == RecipientId || x.InitiatorId == RecipientId && x.RecipientId == InitiatorId).SingleOrDefault(); if (Il != null) { if (Il.InitiatorId == InitiatorId) { return(GameInvitation.RoleInitiator); } else { return(GameInvitation.RoleRecipient); } } return(0); }
/// <summary> /// Start messaging /// </summary> /// <param name="subject"></param> /// <param name="to"></param> /// <param name="callbackUrl"></param> /// <param name="localUserDisplayName"></param> /// <param name="localUserUri"></param> /// <returns></returns> private async Task <IMessagingInvitation> StartMessagingWithIdentityAsync(string subject, string to, string callbackContext, string callbackUrl, string href, string localUserDisplayName, string localUserUri, LoggingContext loggingContext = null) { (Parent as Application).GetCallbackUrlAndCallbackContext(ref callbackUrl, ref callbackContext); string operationId = Guid.NewGuid().ToString(); var tcs = new TaskCompletionSource <IInvitation>(); HandleNewInviteOperationKickedOff(operationId, tcs); IInvitation invite = null; var input = new MessagingInvitationInput { OperationContext = operationId, To = to, Subject = subject, CallbackContext = callbackContext, CallbackUrl = callbackUrl, LocalUserDisplayName = localUserDisplayName, LocalUserUri = localUserUri }; var startMessagingUri = UriHelper.CreateAbsoluteUri(this.BaseUri, href); await this.PostRelatedPlatformResourceAsync(startMessagingUri, input, new ResourceJsonMediaTypeFormatter(), loggingContext).ConfigureAwait(false); try { invite = await tcs.Task.TimeoutAfterAsync(WaitForEvents).ConfigureAwait(false); } catch (TimeoutException) { throw new RemotePlatformServiceException("Timeout to get incoming messaging invitation started event from platformservice!"); } //We are sure the invite sure be there now. var result = invite as MessagingInvitation; if (result == null) { throw new RemotePlatformServiceException("Platformservice do not deliver a messageInvitation resource with operationId " + operationId); } return(result); }
/// <summary> /// Start audio video call /// </summary> /// <param name="subject"></param> /// <param name="to"></param> /// <param name="callbackUrl"></param> /// <returns></returns> private async Task <IAudioVideoInvitation> StartAudioVideoAsync(string href, string subject, string to, string callbackUrl, LoggingContext loggingContext = null) { var operationId = Guid.NewGuid().ToString(); var tcs = new TaskCompletionSource <IInvitation>(); HandleNewInviteOperationKickedOff(operationId, tcs); IInvitation invite = null; var input = new AudioVideoInvitationInput { OperationContext = operationId, To = to, Subject = subject, CallbackUrl = callbackUrl, MediaHost = MediaHostType.Remote }; Uri startAudioVideoUri = UriHelper.CreateAbsoluteUri(this.BaseUri, href); await this.PostRelatedPlatformResourceAsync(startAudioVideoUri, input, new ResourceJsonMediaTypeFormatter(), loggingContext).ConfigureAwait(false); try { invite = await tcs.Task.TimeoutAfterAsync(WaitForEvents).ConfigureAwait(false); } catch (TimeoutException) { throw new RemotePlatformServiceException("Timeout to get incoming audioVideo invitation started event from platformservice!"); } // We are sure that the invite is there now. var result = invite as AudioVideoInvitation; if (result == null) { throw new RemotePlatformServiceException("Platformservice do not deliver a AudioVideoInvitation resource with operationId " + operationId); } return(result); }
public void OnConnected(Android.OS.Bundle connectionHint) { //debugLog("onConnected: connected! client=" + mClientCurrentlyConnecting); // Mark the current client as connected connectedClients |= clientCurrentlyConnecting; // If this was the games client and it came with an invite, store it for // later retrieval. if (clientCurrentlyConnecting == CLIENT_GAMES && connectionHint != null) { //debugLog("onConnected: connection hint provided. Checking for invite."); IInvitation inv = (IInvitation)connectionHint.GetParcelable(GamesClient.ExtraInvitation); if (inv != null && inv.InvitationId != null) { // accept invitation //debugLog("onConnected: connection hint has a room invite!"); invitationId = inv.InvitationId; //debugLog("Invitation ID: " + mInvitationId); } } // connect the next client in line, if any. ConnectNextClient(); }
public IActionResult CreateResponse(Guid id, [FromBody] Models.InvitationResponse response) { IActionResult result = null; if (result == null && id.Equals(Guid.Empty)) { result = BadRequest("Missing id"); } if (result == null && response == null) { result = BadRequest("Missing response data"); } if (result == null) { using (ILifetimeScope scope = m_container.BeginLifetimeScope()) { IInvitationFactory factory = scope.Resolve <IInvitationFactory>(); IInvitation invitation = factory.Get(m_settings.Value, id); if (invitation == null) { result = NotFound(); } else { IInvitationResponse innerResponse = invitation.CreateResponse(response.IsAttending, response.AttendeeCount, response.Note); IInvitationResponseSaver saver = scope.Resolve <IInvitationResponseSaver>(); saver.Create(m_settings.Value, innerResponse); IMapper mapper = new Mapper(m_mapperConfiguration); result = Ok(mapper.Map <Models.InvitationResponse>(innerResponse)); } } } return(result); }
/// <summary> /// Add AudioVideo to an already estalished conversation. /// </summary> /// <param name="loggingContext"><see cref="LoggingContext"/> to use for logging</param> /// <returns><see cref="AudioVideoInvitation"/> which tracks the outgoing invite.</returns> public override async Task <IAudioVideoInvitation> EstablishAsync(LoggingContext loggingContext = null) { string href = PlatformResource?.AddAudioVideoLink?.Href; if (string.IsNullOrWhiteSpace(href)) { throw new CapabilityNotAvailableException("Link to establish AudioVideo is not available."); } Logger.Instance.Information("[AudioVideo] Calling AddAudioVideo. LoggingContext: {0}", loggingContext == null ? string.Empty : loggingContext.ToString()); var conversation = base.Parent as Conversation; if (conversation == null) { Logger.Instance.Error("[AudioVideo] Conversation from AudioVideo base parent is null"); throw new Exception("[AudioVideo] Failed to get Conversation from AudioVideo base parent"); } var communication = conversation.Parent as Communication; if (communication == null) { Logger.Instance.Error("[AudioVideo] Communication from conversation base parent is null"); throw new Exception("[AudioVideo] Failed to get communication from conversation base parent"); } string operationId = Guid.NewGuid().ToString(); var tcs = new TaskCompletionSource <IInvitation>(); //Tracking the incoming invitation from communication resource communication.HandleNewInviteOperationKickedOff(operationId, tcs); IInvitation invite = null; var input = new AudioVideoInvitationInput { OperationContext = operationId, MediaHost = MediaHostType.Remote }; var addAudioVideoUri = UriHelper.CreateAbsoluteUri(this.BaseUri, href); await this.PostRelatedPlatformResourceAsync(addAudioVideoUri, input, new ResourceJsonMediaTypeFormatter(), loggingContext).ConfigureAwait(false); try { invite = await tcs.Task.TimeoutAfterAsync(WaitForEvents).ConfigureAwait(false); } catch (TimeoutException) { throw new RemotePlatformServiceException("Timeout to get incoming AudioVideo invitation started event from platformservice!"); } //We are sure the invite sure be there now. var result = invite as AudioVideoInvitation; if (result == null) { throw new RemotePlatformServiceException("Platformservice do not deliver a AudioVideoInvitation resource with operationId " + operationId); } return(result); }