Example #1
0
        private async Task BloadcastUserMessageAsync(UserProfile user, string userMessage, BingoEntry gameEntry, BingoEntry cardEntry)
        {
            BingoEntry bingoEntry;
            string     gameUserId;

            if (cardEntry != null)
            {
                gameUserId = _tableStorage.FindGameEntry(cardEntry.GameId)?.RowKey;
                bingoEntry = cardEntry;
            }
            else
            {
                bingoEntry = gameEntry;
                gameUserId = gameEntry.RowKey;
            }

            var cardUsers = await _tableStorage.GetCardUsersAsync(bingoEntry.GameId);

            var to = cardUsers
                     .Select(u => u.UserId)
                     .Concat(new[] { gameUserId })
                     .Where(u => u != user.UserId).ToArray();
            await _messagingClient.MultiCastMessageAsync(to,
                                                         new[]
            {
                new TextMessage("@" + user.DisplayName + Environment.NewLine + userMessage)
            });
        }
Example #2
0
        private async Task MulticastMessagesAsync(IList <ISendMessage> messages)
        {
            TableContinuationToken continuationToken = null;

            do
            {
                TableQuery <LineAccountEntity> query = new TableQuery <LineAccountEntity>()
                                                       .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, channelId));
                query.TakeCount = 150;

                TableQuerySegment <LineAccountEntity> querySegment = await accountTable.ExecuteQuerySegmentedAsync(query, continuationToken);

                continuationToken = querySegment.ContinuationToken;

                if (querySegment.Results != null && querySegment.Results.Count > 0)
                {
                    List <string> to = new List <string>(querySegment.Results.Count);
                    foreach (LineAccountEntity account in querySegment)
                    {
                        to.Add(account.Id);
                    }

                    await messagingClient.MultiCastMessageAsync(to, messages);
                }
            }while (continuationToken != null);
        }