Server update 0.63.5

- async lua implementation
- cleaner backend heartbeat
- two way encryption on connect
- async tcp buffer
- disconnect handler
- cleaned UDP implementation
This commit is contained in:
Anonymous275
2020-10-16 17:05:31 +03:00
parent 31c96cee94
commit 71a84b4f1b
14 changed files with 314 additions and 169 deletions

42
include/Buffer.h Normal file
View File

@@ -0,0 +1,42 @@
///
/// Created by Anonymous275 on 8/25/2020
///
#pragma once
#include <mutex>
class Client;
void GParser(Client*c, const std::string&Packet);
class Buffer{
public:
void Handle(Client*c,const std::string& Data){
if(c == nullptr)return;
Buf += Data;
Manage(c);
}
void clear(){
Buf.clear();
}
private:
std::string Buf;
void Manage(Client*c){
if(!Buf.empty()){
std::string::size_type p;
if (Buf.at(0) == '\n'){
p = Buf.find('\n',1);
if(p != -1){
std::string R = Buf.substr(1,p-1);
std::string_view B(R.c_str(),R.find(char(0)));
GParser(c, B.data());
Buf = Buf.substr(p+1);
Manage(c);
}
}else{
p = Buf.find('\n');
if(p == -1)Buf.clear();
else{
Buf = Buf.substr(p);
Manage(c);
}
}
}
}
};