불안정하게 멀티 됨.. 일단은 두번째 플레이어가 첫번째 플레이어한테 보이기는 하니까...
This commit is contained in:
@@ -28,26 +28,29 @@ std::int32_t main(std::int32_t argc, gsl::zstring* argv) {
|
||||
|
||||
addr.set(AF_INET6, "::1", 9010);
|
||||
|
||||
Network::Socket sock;
|
||||
Network::TCPSocket TCPSock;
|
||||
TCPSock.init(AF_INET6);
|
||||
sock = TCPSock;
|
||||
if (sock.connect(addr) == INVALID_SOCKET) {
|
||||
if (TCPSock.connect(addr) == INVALID_SOCKET) {
|
||||
spdlog::error("connect()");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
iocp.registerTCPSocket(sock, 16 * 1024);
|
||||
iocp.registerTCPSocket(TCPSock, 16 * 1024);
|
||||
|
||||
while (iocp.GetRecvedBytes(sock.sock) < 6);
|
||||
while (iocp.GetRecvedBytes(TCPSock.sock) < 6);
|
||||
std::vector<char> header_serialized(6);
|
||||
iocp.recv(sock, header_serialized);
|
||||
iocp.recv(TCPSock, header_serialized);
|
||||
Packet::Header header;
|
||||
header.Deserialize(header_serialized);
|
||||
while (iocp.GetRecvedBytes(sock.sock) < header.body_length);
|
||||
while (iocp.GetRecvedBytes(TCPSock.sock) < header.body_length);
|
||||
std::vector<char> data(header.body_length);
|
||||
iocp.recv(sock, data);
|
||||
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);
|
||||
|
||||
const veng::GlfwInitialization _glfw;
|
||||
|
||||
veng::Window window("Vulkan Engine", {800, 600});
|
||||
@@ -70,7 +73,7 @@ std::int32_t main(std::int32_t argc, gsl::zstring* argv) {
|
||||
glfwPollEvents();
|
||||
|
||||
engine.Update();
|
||||
engine.NetUpdate(std::make_shared<Network::Socket>(sock));
|
||||
engine.NetUpdate(std::make_shared<Network::Socket>(TCPSock));
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user