コード例 #1
0
        public async Task SendPendingMessagesAsync(long nodeId)
        {
            try
            {
                var nodeConnection = _connectionsService.GetNodeConnection(nodeId);
                if (nodeConnection != null)
                {
                    var pendingMessages = await _pendingMessagesService.GetNodePendingMessagesAsync(nodeId).ConfigureAwait(false);

                    if (pendingMessages != null && pendingMessages.Any())
                    {
                        foreach (var message in pendingMessages)
                        {
                            await SendNoticeToNodeAsync(
                                nodeConnection,
                                ObjectSerializer.ByteArrayToObject <NodeNotice>(Convert.FromBase64String(message.Content))).ConfigureAwait(false);
                        }
                        await _pendingMessagesService.RemovePendingMessagesAsync(pendingMessages.Select(message => message.Id)).ConfigureAwait(false);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex);
            }
        }
コード例 #2
0
        private async void SendPendingMessagesAsync()
        {
            try
            {
                var pendingMessages = await pendingMessagesService.GetUserPendingMessagesAsync(clientConnection.UserId.Value).ConfigureAwait(false);

                await pendingMessagesService.RemovePendingMessagesAsync(pendingMessages.Select(message => message.Id)).ConfigureAwait(false);

                noticeService.SendPendingMessagesAsync(pendingMessages, clientConnection.UserId.Value);
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex);
            }
        }