Created basic chained handlers
parent
b8b2bb7202
commit
35edc6ca6e
@ -0,0 +1,16 @@
|
||||
#ifndef EFFCCB40_3639_4BD4_9649_302F05987909
|
||||
#define EFFCCB40_3639_4BD4_9649_302F05987909
|
||||
|
||||
#include <future>
|
||||
#include <string.h>
|
||||
#include "bufHandler.hpp"
|
||||
|
||||
void asyncHandler(char *buf){
|
||||
// Create a copy of buf for our thread
|
||||
char bufCopy[265];
|
||||
strcpy(buf, bufCopy);
|
||||
|
||||
// \/ Surpress unused warning
|
||||
(void)std::async(std::launch::async, bufHandler, bufCopy);
|
||||
}
|
||||
#endif /* EFFCCB40_3639_4BD4_9649_302F05987909 */
|
@ -0,0 +1,22 @@
|
||||
#ifndef C251BA62_6D80_4033_86B6_61F184E6F250
|
||||
#define C251BA62_6D80_4033_86B6_61F184E6F250
|
||||
|
||||
#include <string>
|
||||
#include "textPacketHandler.hpp"
|
||||
|
||||
using namespace std::string_literals;
|
||||
|
||||
std::string buffer = "";
|
||||
void bufHandler(char *buf){
|
||||
// When first char of buf has text (no space), we got a new packet
|
||||
if(buf[0] != ' '){
|
||||
// Submit the just-read text-packet
|
||||
textPacketHandler(buffer);
|
||||
buffer = buf;
|
||||
}else{
|
||||
// Append part-packet
|
||||
buffer += "\n"s + buf;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* C251BA62_6D80_4033_86B6_61F184E6F250 */
|
Loading…
Reference in New Issue