| 125 | } |
| 126 | |
| 127 | ccstd::string SocketIOPacket::toString() const { |
| 128 | std::stringstream encoded; |
| 129 | encoded << this->typeAsNumber(); |
| 130 | encoded << this->_separator; |
| 131 | |
| 132 | ccstd::string pIdL = _pId; |
| 133 | if (_ack == "data") { |
| 134 | pIdL += "+"; |
| 135 | } |
| 136 | |
| 137 | // Do not write pid for acknowledgements |
| 138 | if (_type != "ack") { |
| 139 | encoded << pIdL; |
| 140 | } |
| 141 | encoded << this->_separator; |
| 142 | |
| 143 | // Add the endpoint for the namespace to be used if not the default namespace "" or "/", and as long as it is not an ACK, heartbeat, or disconnect packet |
| 144 | if (_endpoint != "/" && !_endpoint.empty() && _type != "ack" && _type != "heartbeat" && _type != "disconnect") { |
| 145 | encoded << _endpoint << _endpointseparator; |
| 146 | } |
| 147 | encoded << this->_separator; |
| 148 | |
| 149 | if (!_args.empty()) { |
| 150 | ccstd::string ackpId; |
| 151 | // This is an acknowledgement packet, so, prepend the ack pid to the data |
| 152 | if (_type == "ack") { |
| 153 | ackpId += pIdL + "+"; |
| 154 | } |
| 155 | |
| 156 | encoded << ackpId << this->stringify(); |
| 157 | } |
| 158 | |
| 159 | return encoded.str(); |
| 160 | } |
| 161 | int SocketIOPacket::typeAsNumber() const { |
| 162 | ccstd::string::size_type num = 0; |
| 163 | auto item = std::find(_types.begin(), _types.end(), _type); |
nothing calls this directly
no test coverage detected