Exemplo n.º 1
0
        public HttpResponseMessage NotifyNewChat([FromBody] NotifyChatInput notifyChatInput)
        {
            if (notifyChatInput != null && notifyChatInput.RecipientUserIds != null && notifyChatInput.RecipientUserIds.Count > 0)
            {
                var newChatEvent = new NewChatNotificationEvent();
                newChatEvent.Id               = notifyChatInput.Id;
                newChatEvent.GroupName        = notifyChatInput.GroupName;
                newChatEvent.Message          = notifyChatInput.Message;
                newChatEvent.RecipientUserIds = notifyChatInput.RecipientUserIds;
                newChatEvent.SendingUserId    = notifyChatInput.SendingUserId;
                newChatEvent.Type             = notifyChatInput.Type;

                CqrsEvent registerUnitPushEvent = new CqrsEvent();
                registerUnitPushEvent.Type      = (int)CqrsEventTypes.NewChatMessage;
                registerUnitPushEvent.Timestamp = DateTime.UtcNow;
                registerUnitPushEvent.Data      = ObjectSerialization.Serialize(newChatEvent);

                _cqrsProvider.EnqueueCqrsEvent(registerUnitPushEvent);
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> NotifyNewChat([FromBody] NotifyChatInput notifyChatInput)
        {
            if (notifyChatInput != null && notifyChatInput.RecipientUserIds != null && notifyChatInput.RecipientUserIds.Count > 0)
            {
                var newChatEvent = new NewChatNotificationEvent();
                newChatEvent.Id               = notifyChatInput.Id;
                newChatEvent.GroupName        = notifyChatInput.GroupName;
                newChatEvent.Message          = notifyChatInput.Message;
                newChatEvent.RecipientUserIds = notifyChatInput.RecipientUserIds;
                newChatEvent.SendingUserId    = notifyChatInput.SendingUserId;
                newChatEvent.Type             = notifyChatInput.Type;

                CqrsEvent registerUnitPushEvent = new CqrsEvent();
                registerUnitPushEvent.Type      = (int)CqrsEventTypes.NewChatMessage;
                registerUnitPushEvent.Timestamp = DateTime.UtcNow;
                registerUnitPushEvent.Data      = ObjectSerialization.Serialize(newChatEvent);

                await _cqrsProvider.EnqueueCqrsEventAsync(registerUnitPushEvent);
            }

            return(Ok());
        }