Compare commits
3 commits
a20b81836d
...
0ffbcadfb2
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ffbcadfb2 | |||
| 3170ed9bdf | |||
| 9b5225dcb1 |
1 changed files with 17 additions and 4 deletions
21
src/main.cpp
21
src/main.cpp
|
|
@ -1,8 +1,8 @@
|
|||
#include "Logger.hpp"
|
||||
#include "Socket.hpp"
|
||||
|
||||
#include <winsock.h>
|
||||
#include <winsock2.h>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
@ -23,11 +23,24 @@ int main() {
|
|||
* This is where client handling starts.
|
||||
* RECEIVING CLIENT PACKET
|
||||
* 1. Receive raw bytes,
|
||||
* 2. Parse bytes from packet,
|
||||
* 3. Put into components understandable for server.
|
||||
* 2. Parse bytes from packet, put into components understandable for server.
|
||||
*/
|
||||
char buffer[131] = {};
|
||||
buffer[0] = recv(clientSocket, buffer, sizeof(buffer), 0);
|
||||
int bytesRecv = 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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue