mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-06-17 14:12:25 +00:00
websocket wip
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
void WebsocketInit();
|
||||||
std::string GetPlayers(){
|
std::string GetPlayers(){
|
||||||
std::string Return;
|
std::string Return;
|
||||||
for(Client* c : CI->Clients){
|
for(Client* c : CI->Clients){
|
||||||
@@ -31,6 +32,7 @@ std::string GenerateCall(){
|
|||||||
void Heartbeat(){
|
void Heartbeat(){
|
||||||
DebugPrintTID();
|
DebugPrintTID();
|
||||||
std::string R,T;
|
std::string R,T;
|
||||||
|
bool isAuth = false;
|
||||||
while(true){
|
while(true){
|
||||||
R = GenerateCall();
|
R = GenerateCall();
|
||||||
if(!CustomIP.empty())R+="&ip="+CustomIP;
|
if(!CustomIP.empty())R+="&ip="+CustomIP;
|
||||||
@@ -51,6 +53,10 @@ void Heartbeat(){
|
|||||||
if(T.length() == 4)info(Sec("Server authenticated"));
|
if(T.length() == 4)info(Sec("Server authenticated"));
|
||||||
R.clear();
|
R.clear();
|
||||||
T.clear();
|
T.clear();
|
||||||
|
if(!isAuth){
|
||||||
|
WebsocketInit();
|
||||||
|
isAuth = true;
|
||||||
|
}
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(3));
|
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
|
|
||||||
std::string CustomIP;
|
std::string CustomIP;
|
||||||
std::string GetSVer(){
|
std::string GetSVer(){
|
||||||
static std::string r = Sec("0.64");
|
static std::string r = Sec("1.0");
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
std::string GetCVer(){
|
std::string GetCVer(){
|
||||||
static std::string r = Sec("1.63");
|
static std::string r = Sec("1.70");
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
void Args(int argc, char* argv[]){
|
void Args(int argc, char* argv[]){
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
///
|
||||||
|
/// Created by Anonymous275 on 11/6/2020
|
||||||
|
///
|
||||||
|
#include <boost/beast/core.hpp>
|
||||||
|
#include <boost/beast/websocket.hpp>
|
||||||
|
#include <boost/asio/connect.hpp>
|
||||||
|
#include <boost/asio/ip/tcp.hpp>
|
||||||
|
#include "Security/Enc.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include "Logger.h"
|
||||||
|
#include <thread>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace beast = boost::beast;
|
||||||
|
namespace http = beast::http;
|
||||||
|
namespace websocket = beast::websocket;
|
||||||
|
namespace net = boost::asio;
|
||||||
|
using tcp = boost::asio::ip::tcp;
|
||||||
|
//ws.write(asio::buffer("Hello, world!"));
|
||||||
|
// asio::connect(sock,r.resolve(asio::ip::tcp::resolver::query{host, "80"}));
|
||||||
|
// beast::websocket::stream<asio::ip::tcp::socket&> ws(sock);
|
||||||
|
// ws.handshake(host,"/");
|
||||||
|
void SyncData(){
|
||||||
|
DebugPrintTID();
|
||||||
|
using namespace boost;
|
||||||
|
std::string const host = "95.216.35.232";
|
||||||
|
net::io_context ioc;
|
||||||
|
|
||||||
|
tcp::resolver r(ioc);
|
||||||
|
|
||||||
|
websocket::stream<tcp::socket> ws{ioc};
|
||||||
|
auto const results = r.resolve(host, "3600");
|
||||||
|
net::connect(ws.next_layer(), results.begin(), results.end());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WebsocketInit(){
|
||||||
|
std::thread t1(SyncData);
|
||||||
|
t1.detach();
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user