mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-01 23:46:59 +00:00
Fixed Data Size
This commit is contained in:
parent
8f42e319f4
commit
aa875cf8e8
18
proxy.cpp
18
proxy.cpp
@ -8,6 +8,7 @@
|
|||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <WS2tcpip.h>
|
#include <WS2tcpip.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#define DEFAULT_BUFLEN 64000
|
#define DEFAULT_BUFLEN 64000
|
||||||
@ -20,10 +21,14 @@ typedef struct {
|
|||||||
std::string RUDPData;
|
std::string RUDPData;
|
||||||
std::string RUDPToSend;
|
std::string RUDPToSend;
|
||||||
|
|
||||||
|
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wmissing-noreturn"
|
||||||
void TCPServerThread(){
|
void TCPServerThread(){
|
||||||
|
do{
|
||||||
|
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
int iResult;
|
int iResult;
|
||||||
|
|
||||||
SOCKET ListenSocket = INVALID_SOCKET;
|
SOCKET ListenSocket = INVALID_SOCKET;
|
||||||
SOCKET ClientSocket = INVALID_SOCKET;
|
SOCKET ClientSocket = INVALID_SOCKET;
|
||||||
|
|
||||||
@ -101,9 +106,10 @@ void TCPServerThread(){
|
|||||||
|
|
||||||
iResult = recv(ClientSocket, recvbuf, recvbuflen, 0);
|
iResult = recv(ClientSocket, recvbuf, recvbuflen, 0);
|
||||||
if (iResult > 0) {
|
if (iResult > 0) {
|
||||||
printf("Bytes received: %d\n", iResult);
|
|
||||||
printf("Data : %s\n",recvbuf);
|
|
||||||
RUDPToSend = recvbuf;
|
RUDPToSend = recvbuf;
|
||||||
|
RUDPToSend.resize(iResult-1);
|
||||||
|
std::cout << "size : " << RUDPToSend.size() << std::endl;
|
||||||
|
std::cout << "Data : " << RUDPToSend.c_str() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (iResult == 0)
|
else if (iResult == 0)
|
||||||
@ -125,7 +131,10 @@ void TCPServerThread(){
|
|||||||
|
|
||||||
closesocket(ClientSocket);
|
closesocket(ClientSocket);
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
|
}while (true);
|
||||||
}
|
}
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#pragma clang diagnostic pop
|
||||||
void HandleEvent(ENetEvent event,Client client){
|
void HandleEvent(ENetEvent event,Client client){
|
||||||
switch (event.type){
|
switch (event.type){
|
||||||
case ENET_EVENT_TYPE_CONNECT:
|
case ENET_EVENT_TYPE_CONNECT:
|
||||||
@ -181,13 +190,14 @@ void RUDPClientThread(){
|
|||||||
HandleEvent(event,client); //Handles the Events
|
HandleEvent(event,client); //Handles the Events
|
||||||
if(!RUDPToSend.empty()){
|
if(!RUDPToSend.empty()){
|
||||||
ENetPacket* packet = enet_packet_create (RUDPToSend.c_str(),
|
ENetPacket* packet = enet_packet_create (RUDPToSend.c_str(),
|
||||||
RUDPToSend.length()+1,
|
RUDPToSend.size()+1,
|
||||||
ENET_PACKET_FLAG_RELIABLE); //Create A reliable packet using the data
|
ENET_PACKET_FLAG_RELIABLE); //Create A reliable packet using the data
|
||||||
enet_peer_send(client.peer, 0, packet);
|
enet_peer_send(client.peer, 0, packet);
|
||||||
RUDPToSend.clear();
|
RUDPToSend.clear();
|
||||||
}
|
}
|
||||||
Sleep(50);
|
Sleep(50);
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user