Add "fin" to intersection iterator

This commit is contained in:
Alex Hultman
2021-01-29 12:21:46 +01:00
parent ac7c72698d
commit dc423cfda2
2 changed files with 19 additions and 4 deletions
+15 -1
View File
@@ -19,11 +19,25 @@ void testCorrectness() {
topicTree = new uWS::TopicTree([&topicTree, &actualResult](uWS::Subscriber *s, uWS::Intersection &intersection) {
intersection.forSubscriber(topicTree->getSenderFor(s), [s, &actualResult](std::pair<std::string_view, std::string_view> dataChannels) {
/* How many bytes we have in first data channel at time we get fin = true */
unsigned int finAt = 0;
intersection.forSubscriber(topicTree->getSenderFor(s), [s, &finAt, &actualResult](std::pair<std::string_view, std::string_view> dataChannels, bool fin) {
actualResult[s].first += dataChannels.first;
actualResult[s].second += dataChannels.second;
/* Check that getting fin = true really is the last segment */
if (!finAt && fin) {
finAt = actualResult[s].first.length();
}
});
/* Assume finAt == actualResult[s].first.length() */
if (actualResult[s].first.length() != finAt) {
std::cout << "ERROR! FinAt mismatching!" << std::endl;
exit(1);
}
/* We actually don't use this one */
return 0;
});