File Coverage

src/panda/protocol/websocket/Message.cc
Criterion Covered Total %
statement 20 20 100.0
branch 19 22 86.3
condition n/a
subroutine n/a
pod n/a
total 39 42 92.8


line stmt bran cond sub pod time code
1             #include "Message.h"
2             #include
3              
4             namespace panda { namespace protocol { namespace websocket {
5              
6 348           bool Message::add_frame (const Frame& frame) {
7 348 50         assert(_state != State::DONE);
8              
9 348 100         if (frame.error) {
10 24           error = frame.error;
11 24           _state = State::DONE;
12 24           return true;
13             }
14              
15 324 100         if (!frame_count++) {
16 194           _opcode = frame.opcode();
17 194 100         if (_opcode == Opcode::CLOSE) {
18 6           _close_code = frame.close_code();
19 6 50         _close_message = frame.close_message();
20             }
21             }
22              
23 324 100         if (_max_size && _payload_length + frame.payload_length() > _max_size) {
    100          
    100          
24 2           error = errc::max_message_size;
25 2           _state = State::DONE;
26 2           return true;
27             }
28              
29 2614 100         for (const auto& s : frame.payload) {
30 2292           _payload_length += s.length();
31 2292 50         payload.push_back(s);
32             }
33              
34 322 100         if (frame.final()) _state = State::DONE;
35              
36 348           return _state == State::DONE;
37             }
38              
39             }}}