/// <summary> /// Pulls the messaged from pub sub. /// </summary> /// <param name="ct">The ct.</param> protected static async Task <bool> PullMessagedFromPubSubAsync(CancellationToken ct) { bool bStatus = true; FirebaseTestSender.Init(); var firebasenet = new FirebaseTestSender(); Stopwatch stopWatch = new Stopwatch(); long length = 0; lock (_redisOperationLock){ length = _redisDB.ListLength(PendingQueue); } long numOfMsg = length - 1; RedisValue message = new RedisValue(); FCMClient client = new FCMClient(serverKey); while (length > 0) { lock (_redisOperationLock){ length = _redisDB.ListLength(PendingQueue); if (length >= 1) { message = _redisDB.ListRightPop(PendingQueue); } } if (length >= 1) { Dictionary <String, String> convertedMessage = null; String[] recievedRegistration_ids; bool converted = ConvertMessageWithTokens(message, out convertedMessage, out recievedRegistration_ids); firebasenet.SenderDataPayloadToFirebaseAsync(convertedMessage, recievedRegistration_ids, client); } lock (_redisOperationLock){ length = _redisDB.ListLength(PendingQueue); } } while (true) { bool isFinished = CheckMessagesStatus(); if (isFinished) { break; } Thread.Sleep(50); } return(bStatus); }
private static void DoSomeWork(RedisValue[] msgCollection, FCMClient client) { var firebasenet = new FirebaseTestSender(); foreach (var m in msgCollection) { Dictionary <String, String> convertedMessage = null; String[] recievedRegistration_ids; bool converted = ConvertMessageWithTokens(m, out convertedMessage, out recievedRegistration_ids); firebasenet.SenderDataPayloadToFirebaseAsync(convertedMessage, recievedRegistration_ids, client); } ; }