diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-07-21 13:38:59 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-07-21 13:38:59 -0700 |
commit | 3f8a5b8b7690e8572d310bcca532602c503ff2c4 (patch) | |
tree | 1e2acd98ea173472c9ea608e310eef09fb8ee72b /controller/SqliteNetworkController.cpp | |
parent | a061aa3d872c25a845cf698d2d6e95863297834e (diff) | |
download | infinitytier-3f8a5b8b7690e8572d310bcca532602c503ff2c4.tar.gz infinitytier-3f8a5b8b7690e8572d310bcca532602c503ff2c4.zip |
List members in the form of a hash of member ID and member revision so code can quickly detect which members have changed.
Diffstat (limited to 'controller/SqliteNetworkController.cpp')
-rw-r--r-- | controller/SqliteNetworkController.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/controller/SqliteNetworkController.cpp b/controller/SqliteNetworkController.cpp index 1d121ed3..c663d1de 100644 --- a/controller/SqliteNetworkController.cpp +++ b/controller/SqliteNetworkController.cpp @@ -193,7 +193,7 @@ SqliteNetworkController::SqliteNetworkController(const char *dbPath) : ||(sqlite3_prepare_v2(_db,"SELECT m.authorized,m.activeBridge,m.memberRevision,n.identity FROM Member AS m JOIN Node AS n ON n.id = m.nodeId WHERE m.networkId = ? AND m.nodeId = ?",-1,&_sGetMember2,(const char **)0) != SQLITE_OK) ||(sqlite3_prepare_v2(_db,"INSERT INTO Member (networkId,nodeId,authorized,activeBridge,memberRevision) VALUES (?,?,?,0,(SELECT memberRevisionCounter FROM Network WHERE id = ?))",-1,&_sCreateMember,(const char **)0) != SQLITE_OK) ||(sqlite3_prepare_v2(_db,"SELECT nodeId FROM Member WHERE networkId = ? AND activeBridge > 0 AND authorized > 0",-1,&_sGetActiveBridges,(const char **)0) != SQLITE_OK) - ||(sqlite3_prepare_v2(_db,"SELECT m.nodeId FROM Member AS m WHERE m.networkId = ? ORDER BY m.nodeId ASC",-1,&_sListNetworkMembers,(const char **)0) != SQLITE_OK) + ||(sqlite3_prepare_v2(_db,"SELECT m.nodeId,m.memberRevision FROM Member AS m WHERE m.networkId = ? ORDER BY m.nodeId ASC",-1,&_sListNetworkMembers,(const char **)0) != SQLITE_OK) ||(sqlite3_prepare_v2(_db,"UPDATE Member SET authorized = ?,memberRevision = (SELECT memberRevisionCounter FROM Network WHERE id = ?) WHERE rowid = ?",-1,&_sUpdateMemberAuthorized,(const char **)0) != SQLITE_OK) ||(sqlite3_prepare_v2(_db,"UPDATE Member SET activeBridge = ?,memberRevision = (SELECT memberRevisionCounter FROM Network WHERE id = ?) WHERE rowid = ?",-1,&_sUpdateMemberActiveBridge,(const char **)0) != SQLITE_OK) ||(sqlite3_prepare_v2(_db,"DELETE FROM Member WHERE networkId = ? AND nodeId = ?",-1,&_sDeleteMember,(const char **)0) != SQLITE_OK) @@ -1395,10 +1395,11 @@ unsigned int SqliteNetworkController::_doCPGet( sqlite3_reset(_sListNetworkMembers); sqlite3_bind_text(_sListNetworkMembers,1,nwids,16,SQLITE_STATIC); while (sqlite3_step(_sListNetworkMembers) == SQLITE_ROW) { - responseBody.push_back((responseBody.length()) ? ',' : '['); - responseBody.push_back('"'); + responseBody.append((responseBody.length() > 0) ? ",{\"" : "[{\""); responseBody.append((const char *)sqlite3_column_text(_sListNetworkMembers,0)); - responseBody.push_back('"'); + responseBody.append("\":"); + responseBody.append((const char *)sqlite3_column_text(_sListNetworkMembers,1)); + responseBody.push_back('}'); } responseBody.push_back(']'); responseContentType = "application/json"; |