Commit 9a8df83b authored by Guillaume BIENKOWSKI's avatar Guillaume BIENKOWSKI

Untested msgpack serialization

parent e151bcae
......@@ -239,6 +239,17 @@ if(ENABLE_SOCI)
find_path(SOCI_MYSQL_INCLUDES NAMES mysql.h PATH_SUFFIXES mysql)
endif()
find_path(MSGPACK_INCLUDE_DIRS NAMES msgpack.hpp HINTS /usr/local/include)
if(MSGPACK_INCLUDE_DIRS)
message(STATUS "MSGPACK found")
add_definitions("-DENABLE_MSGPACK")
set(ENABLE_MSGPACK 1)
else()
message(STATUS "MSGPACK not found")
endif()
if(ENABLE_PUSHNOTIFICATION)
find_package(OpenSSL 0.9.8 REQUIRED)
endif()
......
......@@ -117,6 +117,11 @@ if(ENABLE_XSD)
ADD_XSD_WRAPPERS(fthttp "Generating XSD for FTHTTP")
endif()
if(ENABLE_MSGPACK)
message(STATUS "Enabling MSGPACK with includes at ${MSGPACK_INCLUDE_DIRS}")
list(APPEND FLEXISIP_INCLUDES ${MSGPACK_INCLUDE_DIRS})
list(APPEND FLEXISIP_SOURCES recordserializer-msgpack.cc)
endif()
if(ENABLE_ODB)
......@@ -258,3 +263,17 @@ if (ENABLE_PUSHNOTIFICATION)
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
add_executable(flexisip_serializer tools/serializer.cc)
target_link_libraries(flexisip_serializer flexisip)
set_property(TARGET flexisip_serializer PROPERTY CXX_STANDARD 11)
set_property(TARGET flexisip_serializer PROPERTY CXX_STANDARD_REQUIRED ON)
install(TARGETS flexisip_serializer
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
......@@ -125,7 +125,7 @@ class ModuleRegistrar : public Module, public ModuleToolbox {
{Integer, "redis-server-port", "Port of the redis server.", "6379"},
{String, "redis-auth-password", "Authentication password for redis. Empty to disable.", ""},
{Integer, "redis-server-timeout", "Timeout in milliseconds of the redis connection.", "1500"},
{String, "redis-record-serializer", "Serialize contacts with: [C, protobuf]", "protobuf"},
{String, "redis-record-serializer", "Serialize contacts with: [C, protobuf, json, msgpack]", "protobuf"},
{Integer, "redis-slave-check-period", "When Redis is configured in master-slave, flexisip will "
"periodically ask what are the slaves and the master."
"This is the period with which it will query the server."
......
......@@ -63,4 +63,13 @@ class RecordSerializerPb : public RecordSerializer {
};
#endif
#ifdef ENABLE_MSGPACK
class RecordSerializerMsgPack : public RecordSerializer {
public:
RecordSerializerMsgPack();
virtual bool parse(const char *str, int len, Record *r);
virtual bool serialize(Record *r, std::string &serialized, bool log);
};
#endif
#endif
......@@ -716,6 +716,11 @@ RecordSerializer *RecordSerializer::create(const string &name) {
else if (name == "protobuf") {
return new RecordSerializerPb();
}
#endif
#if ENABLE_MSGPACK
else if (name == "msgpack"){
return new RecordSerializerMsgPack();
}
#endif
else {
return NULL;
......
......@@ -78,6 +78,8 @@ int test_bind_without_ecc(ExtendedContactCommon &ecc, const unique_ptr<RecordSer
if (!serializer->serialize(&initial, serialized, true)) {
cerr << "Failed serializing" << endl;
return -1;
} else {
cout << "Serialized size: " << serialized.length() << endl;
}
Record final("key");
......@@ -111,7 +113,7 @@ int main(int argc, char **argv) {
int expire_delta = 1000;
list<string> paths{"path1", "path2", "path3"};
string contactid{"ip:5223"};
string contactid{"192.168.0.1:5223"};
string callid{"callid"};
string line{"line"};
string contact = "sip:" + contactid + ";line=" + line;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment