11111
This commit is contained in:
@@ -7,8 +7,9 @@
|
||||
#include <ctime>
|
||||
#include <sstream>
|
||||
#include <chrono>
|
||||
#include <asio.hpp>
|
||||
#include <asio/ssl.hpp>
|
||||
#include "SqrReqScript.hpp"
|
||||
|
||||
using asio::ip::tcp;
|
||||
|
||||
static char szGamePathA[256];
|
||||
void setupLogger()
|
||||
@@ -45,16 +46,6 @@ HSQUIRRELVM v;
|
||||
// Lock
|
||||
std::recursive_mutex SqMtx;
|
||||
|
||||
// static void printfunc(HSQUIRRELVM v, const SQChar *s, ...)
|
||||
// {
|
||||
// fflush(stdout);
|
||||
// va_list vl;
|
||||
// va_start(vl, s);
|
||||
// scvprintf(stdout, s, vl);
|
||||
// va_end(vl);
|
||||
// printf("\n");
|
||||
// fflush(stdout);
|
||||
// }
|
||||
static void printfunc(HSQUIRRELVM v, const SQChar *s, ...)
|
||||
{
|
||||
va_list vl;
|
||||
@@ -66,16 +57,6 @@ static void printfunc(HSQUIRRELVM v, const SQChar *s, ...)
|
||||
spdlog::info(buf);
|
||||
}
|
||||
|
||||
// static void errorfunc(HSQUIRRELVM v, const SQChar *s, ...)
|
||||
// {
|
||||
// fflush(stderr);
|
||||
// va_list vl;
|
||||
// va_start(vl, s);
|
||||
// scvprintf(stderr, s, vl);
|
||||
// va_end(vl);
|
||||
// printf("\n");
|
||||
// fflush(stderr);
|
||||
// }
|
||||
static void errorfunc(HSQUIRRELVM v, const SQChar *s, ...)
|
||||
{
|
||||
va_list vl;
|
||||
@@ -180,51 +161,17 @@ static void ReloadingScript(HSQUIRRELVM v, std::string FilePath)
|
||||
|
||||
static SQInteger SqReloadScript(HSQUIRRELVM v)
|
||||
{
|
||||
ReloadingScript(v, "/dp_s/Dps_A/");
|
||||
ReloadingScript(v, "/dp_s/Dps_B/");
|
||||
ReloadingScript(v, "/dp_s/Dps_C/");
|
||||
// ReloadingScript(v, "/dp_s/Dps_A/");
|
||||
// ReloadingScript(v, "/dp_s/Dps_B/");
|
||||
// ReloadingScript(v, "/dp_s/Dps_C/");
|
||||
ReqSquirrelScript(v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void InitSquirrel()
|
||||
{
|
||||
std::cout << "OpenSSL version: " << OPENSSL_VERSION_TEXT << std::endl;
|
||||
|
||||
asio::io_context io_context;
|
||||
asio::ssl::context ctx(asio::ssl::context::tlsv12_client);
|
||||
|
||||
asio::ssl::stream<asio::ip::tcp::socket> socket(io_context, ctx);
|
||||
|
||||
asio::ip::tcp::resolver resolver(io_context);
|
||||
auto endpoints = resolver.resolve("www.rindro.cn", "https");
|
||||
|
||||
asio::connect(socket.lowest_layer(), endpoints);
|
||||
|
||||
socket.handshake(asio::ssl::stream_base::handshake_type::client);
|
||||
|
||||
std::string post_data = "key1=value1&key2=value2";
|
||||
std::string request = "POST /c/user/getServiceUrl HTTP/1.1\r\n";
|
||||
request += "Host: www.rindro.cn\r\n";
|
||||
request += "Content-Length: " + std::to_string(post_data.size()) + "\r\n";
|
||||
request += "Content-Type: application/x-www-form-urlencoded\r\n";
|
||||
request += "\r\n";
|
||||
request += post_data;
|
||||
|
||||
asio::write(socket, asio::buffer(request));
|
||||
|
||||
asio::streambuf response;
|
||||
asio::read_until(socket, response, "\r\n");
|
||||
|
||||
std::istream response_stream(&response);
|
||||
std::string http_version;
|
||||
response_stream >> http_version;
|
||||
|
||||
std::stringstream ss;
|
||||
ss << &response;
|
||||
std::string response_data = ss.str();
|
||||
std::cout << "Server Response: " << response_data << std::endl;
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(SqMtx);
|
||||
std::lock_guard<std::recursive_mutex>
|
||||
lock(SqMtx);
|
||||
|
||||
v = sq_open(4096); // 创建虚拟机,其栈的初始大小为1024
|
||||
|
||||
@@ -246,10 +193,13 @@ void InitSquirrel()
|
||||
// 注册全局NutApi
|
||||
GlobaRegisterSquirrel(v);
|
||||
|
||||
// 从网络加载脚本
|
||||
ReqSquirrelScript(v);
|
||||
|
||||
// 加载基础脚本文件
|
||||
ReloadingScript(v, "/dp_s/Dps_A/");
|
||||
ReloadingScript(v, "/dp_s/Dps_B/");
|
||||
ReloadingScript(v, "/dp_s/Dps_C/");
|
||||
// ReloadingScript(v, "/dp_s/Dps_A/");
|
||||
// ReloadingScript(v, "/dp_s/Dps_B/");
|
||||
// ReloadingScript(v, "/dp_s/Dps_C/");
|
||||
|
||||
// 执行虚拟机Main函数
|
||||
SQInteger top = sq_gettop(v); // saves the stack size before the call
|
||||
|
||||
Reference in New Issue
Block a user