77 {
78 message_.clear();
79 std::string &message = channel_messages_[channel];
80
81 message.append(reinterpret_cast<const char *>(data_start),
82 std::distance(data_start, data_end));
83 std::string::iterator it_s = message.begin();
84 for (auto it = message.begin(); it != message.end(); ++it) {
85 if (*it == '$' || *it == '#') {
86 it_s = it;
87 continue;
88 }
89 if (*it == 0x0A) {
90 if (*it_s == '$' || *it_s == '#') {
91 message_.assign(it_s, it);
92 } else {
93 AERROR <<
"invalid ascii message: " << message;
94 }
95 it_s = it + 1;
96 }
97 }
98 if (it_s != message.end()) {
99 message.assign(it_s, message.end());
100 } else {
101 message.clear();
102 }
103 }