일단은 멀티로 접속이 됨..

This commit is contained in:
2025-06-19 02:42:49 +09:00
parent 1b79d946c3
commit fc8217a608
25 changed files with 584 additions and 574 deletions

View File

@@ -9,6 +9,7 @@
#include "socket/wsa_manager.h"
#include "utils/log.h"
#include "utils/snowflake.h"
#include "utils/utils.h"
#include "vulkan_engine/vulkan/engine.h"
#include "vulkan_engine/vulkan/graphics.h"
@@ -28,28 +29,24 @@ std::int32_t main(std::int32_t argc, gsl::zstring* argv) {
addr.set(AF_INET6, "::1", 9010);
Network::TCPSocket TCPSock;
TCPSock.init(AF_INET6);
if (TCPSock.connect(addr) == INVALID_SOCKET) {
std::shared_ptr<Network::TCPSocket> TCPSock =
std::make_shared<Network::TCPSocket>();
TCPSock->init(AF_INET6);
if (TCPSock->connect(addr) == INVALID_SOCKET) {
spdlog::error("connect()");
std::exit(EXIT_FAILURE);
}
iocp.registerTCPSocket(TCPSock, 16 * 1024);
iocp.registerSocket(TCPSock);
auto result = iocp.recv(TCPSock, 14);
auto header_serialized = utils::CvtListToVector(result.get());
while (iocp.GetRecvedBytes(TCPSock.sock) < 6);
std::vector<char> header_serialized(6);
iocp.recv(TCPSock, header_serialized);
Packet::Header header;
header.Deserialize(header_serialized);
while (iocp.GetRecvedBytes(TCPSock.sock) < header.body_length);
std::vector<char> data(header.body_length);
iocp.recv(TCPSock, data);
::memcpy(&CLIENTID, data.data(), 1); //id 받기
header.opcode = Packet::Opcode::CLIENTID;
header.body_length = 0;
header_serialized = header.Serialize();
iocp.send(TCPSock, header_serialized);
result = iocp.recv(TCPSock, header.body_length);
std::vector<char> data = utils::CvtListToVector(result.get());
::memcpy(&CLIENTID, data.data(), 1); // id 받기
const veng::GlfwInitialization _glfw;
@@ -69,11 +66,17 @@ std::int32_t main(std::int32_t argc, gsl::zstring* argv) {
engine.init();
tp.enqueueJob(
[engine = &engine, TCPSock](utils::ThreadPool* tp, std::uint32_t __) {
engine->ResponseToServerAndRefresh(TCPSock);
},
0);
while (!window.ShouldClose()) {
glfwPollEvents();
engine.Update();
engine.NetUpdate(std::make_shared<Network::Socket>(TCPSock));
engine.NetUpdate(TCPSock);
}
return EXIT_SUCCESS;