mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-02-16 02:30:54 +00:00
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:
42
include/Buffer.h
Normal file
42
include/Buffer.h
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
#include <WS2tcpip.h>
|
||||
#include "Buffer.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <chrono>
|
||||
@@ -48,6 +49,7 @@ public:
|
||||
int GetCarCount();
|
||||
void ClearCars();
|
||||
int GetStatus();
|
||||
Buffer Handler;
|
||||
int GetID();
|
||||
};
|
||||
struct ClientInterface{
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "lua.hpp"
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <any>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
@@ -50,17 +51,15 @@ public:
|
||||
void SetPluginName(const std::string&Name);
|
||||
void SetFileName(const std::string&Name);
|
||||
fs::file_time_type GetLastWrite();
|
||||
bool isThreadExecuting = false;
|
||||
std::string GetPluginName();
|
||||
std::string GetFileName();
|
||||
bool isExecuting = false;
|
||||
bool StopThread = false;
|
||||
bool HasThread = false;
|
||||
lua_State* GetState();
|
||||
char* GetOrigin();
|
||||
std::mutex Lock;
|
||||
void Reload();
|
||||
void Init();
|
||||
};
|
||||
int CallFunction(Lua*lua,const std::string& FuncName,LuaArg* args);
|
||||
int TriggerLuaEvent(const std::string& Event,bool local,Lua*Caller,LuaArg* arg);
|
||||
int TriggerLuaEvent(const std::string& Event,bool local,Lua*Caller,LuaArg* arg,bool Wait);
|
||||
extern std::set<Lua*> PluginEngine;
|
||||
@@ -12,8 +12,8 @@ void SyncResources(Client*c);
|
||||
[[noreturn]] void UDPServerMain();
|
||||
void OnDisconnect(Client*c,bool kicked);
|
||||
void UDPSend(Client*c,std::string Data);
|
||||
void TCPSend(Client*c,const std::string&Data);
|
||||
void SendLarge(Client*c,const std::string&Data);
|
||||
void TCPSend(Client*c,const std::string& Data);
|
||||
void SendLarge(Client*c,std::string Data);
|
||||
void GParser(Client*c, const std::string&Packet);
|
||||
void Respond(Client*c, const std::string& MSG, bool Rel);
|
||||
void SendToAll(Client*c, const std::string& Data, bool Self, bool Rel);
|
||||
|
||||
@@ -10,6 +10,7 @@ struct RSA{
|
||||
int e = 0;
|
||||
int d = 0;
|
||||
};
|
||||
std::string RSA_E(const std::string& Data,int e, int n);
|
||||
std::string RSA_E(const std::string& Data, RSA*k);
|
||||
std::string RSA_D(const std::string& Data, RSA*k);
|
||||
int Handle(EXCEPTION_POINTERS *ep,char* Origin);
|
||||
|
||||
Reference in New Issue
Block a user