@@ -84,24 +84,32 @@ void ProxySupervisor::listenToSocket() {
84
84
exit (-1 );
85
85
}
86
86
if (readAmount > 0 ) {
87
- try {
88
- nlohmann::basic_json<> parsed = nlohmann::json::parse (message);
89
- printf (" parseJSON: %s\n " , parsed.dump ().c_str ());
90
-
91
- if (isEvent (parsed)) {
92
- CallbackHandler::push_event (new Event (
93
- *parsed.find (" topic" ), *parsed.find (" payload" )));
94
- WARDuino::instance ()->debugger ->notifyPushedEvent ();
87
+ std::string msg_str = std::string (reinterpret_cast <char *>(message));
88
+ printf (" msg_str = \" %s\"\n " , (char *) message);
89
+ while (!msg_str.empty ()) {
90
+ auto first_msg = msg_str.substr (0 , msg_str.find (' \n ' ));
91
+ msg_str = msg_str.substr (msg_str.find (' \n ' ) + 1 );
92
+ printf (" first_msg = \" %s\"\n " , first_msg.c_str ());
93
+
94
+ try {
95
+ nlohmann::basic_json<> parsed = nlohmann::json::parse (first_msg);
96
+ printf (" parseJSON: %s\n " , parsed.dump ().c_str ());
97
+
98
+ if (isEvent (parsed)) {
99
+ CallbackHandler::push_event (new Event (
100
+ *parsed.find (" topic" ), *parsed.find (" payload" )));
101
+ WARDuino::instance ()->debugger ->notifyPushedEvent ();
102
+ }
103
+
104
+ if (isReply (parsed)) {
105
+ this ->hasReplied = true ;
106
+ this ->proxyResult = parsed;
107
+ }
108
+ } catch (const nlohmann::detail::parse_error &e) {
109
+ // printf("Non RFC call: %s\n", first_msg.c_str());
110
+ // printf("error: %s\n", e.what());
111
+ WARDuino::instance ()->handleInterrupt (readAmount, (uint8_t *) first_msg.c_str ());
95
112
}
96
-
97
- if (isReply (parsed)) {
98
- this ->hasReplied = true ;
99
- this ->proxyResult = parsed;
100
- }
101
- } catch (const nlohmann::detail::parse_error &e) {
102
- printf (" Non RFC call: %s" , message);
103
- printf (" error: %s" , e.what ());
104
- WARDuino::instance ()->handleInterrupt (readAmount, message);
105
113
}
106
114
}
107
115
}
0 commit comments