Compare commits
No commits in common. "0ffbcadfb2259301006ef3e468790e7e4cf0cc6d" and "a20b81836dc360009f6b676ea1c9298d6716a8db" have entirely different histories.
0ffbcadfb2
...
a20b81836d
1 changed files with 4 additions and 17 deletions
21
src/main.cpp
21
src/main.cpp
|
|
@ -1,8 +1,8 @@
|
||||||
#include "Logger.hpp"
|
#include "Logger.hpp"
|
||||||
#include "Socket.hpp"
|
#include "Socket.hpp"
|
||||||
|
|
||||||
|
#include <winsock.h>
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
@ -23,24 +23,11 @@ int main() {
|
||||||
* This is where client handling starts.
|
* This is where client handling starts.
|
||||||
* RECEIVING CLIENT PACKET
|
* RECEIVING CLIENT PACKET
|
||||||
* 1. Receive raw bytes,
|
* 1. Receive raw bytes,
|
||||||
* 2. Parse bytes from packet, put into components understandable for server.
|
* 2. Parse bytes from packet,
|
||||||
|
* 3. Put into components understandable for server.
|
||||||
*/
|
*/
|
||||||
char buffer[131] = {};
|
char buffer[131] = {};
|
||||||
int bytesRecv = recv(clientSocket, buffer, sizeof(buffer), 0);
|
buffer[0] = recv(clientSocket, buffer, sizeof(buffer), 0);
|
||||||
|
|
||||||
if(bytesRecv <= 0){
|
|
||||||
log.err("No bytes received");
|
|
||||||
closesocket(clientSocket);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t packID = buffer[0];
|
|
||||||
uint8_t protVer = buffer[1];
|
|
||||||
string username; username.assign(buffer + 2, 64);
|
|
||||||
string verKey; verKey.assign(buffer + 66, 64);
|
|
||||||
uint8_t unused = buffer[130];
|
|
||||||
|
|
||||||
log.info(username + " connected");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue