truncate module

This commit is contained in:
Benjamin Sergeant 2019-09-03 20:14:35 -07:00
parent 98189c23dc
commit 12c3275c36

View File

@ -43,6 +43,21 @@
#include <ixwebsocket/IXSocket.h> #include <ixwebsocket/IXSocket.h>
namespace
{
std::string truncate(const std::string& str, size_t n)
{
if (str.size() < n)
{
return str;
}
else
{
return str.substr(0, n) + "...";
}
}
}
namespace ix namespace ix
{ {
class AutobahnTestCase class AutobahnTestCase
@ -117,7 +132,7 @@ namespace ix
ss << "Received " << msg->wireSize << " bytes" << std::endl; ss << "Received " << msg->wireSize << " bytes" << std::endl;
ss << "autobahn: received message: " ss << "autobahn: received message: "
<< msg->str << truncate(msg->str, 40)
<< std::endl; << std::endl;
_webSocket.send(msg->str, msg->binary); _webSocket.send(msg->str, msg->binary);