summary refs log tree commit diff
diff options
context:
space:
mode:
authorNewe <speedy.wolfy@outlook.com>2021-05-25 23:07:44 +0200
committerNewe <speedy.wolfy@outlook.com>2021-05-25 23:07:44 +0200
commite98e307aedc195ba2adafa3129aa60c84fc8efa5 (patch)
tree4c6bb87339ba03d633e2e0561957300100c5a22c
parent[add] Mongo collection insert :) (diff)
downloadserver-e98e307aedc195ba2adafa3129aa60c84fc8efa5.tar.xz
[edit] Ignore event if emited by a vServer
-rw-r--r--src/mongoStub.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/mongoStub.cpp b/src/mongoStub.cpp
index 7e5c4a6c..03744bd4 100644
--- a/src/mongoStub.cpp
+++ b/src/mongoStub.cpp
@@ -34,9 +34,14 @@ std::vector<mongoStub::mongoMessage> mongoStub::getNewMessages(
         }
         std::string evNameTmp =
             event["fullDocument"]["event"].get_utf8().value.to_string();
+
+		if(evNameTmp.substr(0, 7)=="VSERVER"){ continue; } //Ignore the event if it's been emited by a voice server
+
         if (evNameTmp == "UDP_CONNECTION") {
             handleUdpRequest();
+
         } else if (evNameTmp == "VOICE_REQUEST") {
+			//TODO
             continue;
         }
 
@@ -47,6 +52,7 @@ std::vector<mongoStub::mongoMessage> mongoStub::getNewMessages(
     return retVec;
 }
 
+//------- ABOVE THIS LINE IS COPY & PASTE HAVEN -------
 void mongoStub::handleUdpRequest() {
     using bsoncxx::builder::basic::kvp;
     using bsoncxx::builder::basic::sub_array;
@@ -68,4 +74,23 @@ void mongoStub::handleUdpRequest() {
 	std::cout << "Insert"<< std::endl;
 }
 
-void handleVoiceRequest() {}
\ No newline at end of file
+void mongoStub::handleVoiceRequest() {
+	using bsoncxx::builder::basic::kvp;
+    using bsoncxx::builder::basic::sub_array;
+    using bsoncxx::builder::basic::sub_document;
+
+    auto builder = bsoncxx::builder::basic::document{};
+
+    builder.append(kvp("event", "VSERVER_UDP_RESPONSE"));
+    builder.append(kvp("op", "4"));
+    builder.append(kvp("d", [](sub_document subdoc) {
+			subdoc.append(kvp("mode", "CRYPT_MODE")),
+			subdoc.append(kvp("secret_key", [](sub_array subarr) {
+            	subarr.append(1, 2, 3, 5);  // HOW DO I GEN A SKEY?
+        	}));
+		}));
+	
+	
+	bsoncxx::stdx::optional<mongocxx::result::insert_one> r= col.insert_one(builder.view());
+	std::cout << "Insert"<< std::endl;
+}
\ No newline at end of file