you can look at this one its ok
This commit is contained in:
parent
5929a397cc
commit
5bc9356f04
9 changed files with 31 additions and 15 deletions
10
PROTOCOL.md
10
PROTOCOL.md
|
@ -163,7 +163,7 @@ Communication between the master server and clients will be done over a WebSocke
|
|||
<table style="margin-right: 8px; margin-bottom: 8px;">
|
||||
<thead>
|
||||
<th colspan="100" class="center">
|
||||
ID 0: Login Attempt<br />
|
||||
ID 0: Login Response<br />
|
||||
Responder
|
||||
</th>
|
||||
</thead>
|
||||
|
@ -197,7 +197,7 @@ Communication between the master server and clients will be done over a WebSocke
|
|||
<table style="margin-right: 8px; margin-bottom: 8px;">
|
||||
<thead>
|
||||
<th colspan="100" class="center">
|
||||
ID 1: Registration Attempt<br />
|
||||
ID 1: Registration Response<br />
|
||||
Responder
|
||||
</th>
|
||||
</thead>
|
||||
|
@ -221,7 +221,7 @@ Communication between the master server and clients will be done over a WebSocke
|
|||
<table style="margin-right: 8px; margin-bottom: 8px;">
|
||||
<thead>
|
||||
<th colspan="100" class="center">
|
||||
ID 2: Server List Request<br />
|
||||
ID 2: Server Listing<br />
|
||||
Responder
|
||||
</th>
|
||||
</thead>
|
||||
|
@ -256,7 +256,7 @@ Communication between the master server and clients will be done over a WebSocke
|
|||
<table style="margin-right: 8px; margin-bottom: 8px;">
|
||||
<thead>
|
||||
<th colspan="100" class="center">
|
||||
ID 0: Login Attempt<br />
|
||||
ID 0: Login Request<br />
|
||||
Requester
|
||||
</th>
|
||||
</thead>
|
||||
|
@ -285,7 +285,7 @@ Communication between the master server and clients will be done over a WebSocke
|
|||
<table style="margin-right: 8px; margin-bottom: 8px;">
|
||||
<thead>
|
||||
<th colspan="100" class="center">
|
||||
ID 1: Registration Attempt<br />
|
||||
ID 1: Registration Request<br />
|
||||
Requester
|
||||
</th>
|
||||
</thead>
|
||||
|
|
5
src/client/sock/socket.cpp
Normal file
5
src/client/sock/socket.cpp
Normal file
|
@ -0,0 +1,5 @@
|
|||
//
|
||||
// Created by alec on 10/16/2018.
|
||||
//
|
||||
|
||||
#include "socket.hpp"
|
4
src/client/sock/socket.hpp
Normal file
4
src/client/sock/socket.hpp
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef SOSC_CLIENT_SOCKET_H
|
||||
#define SOSC_CLIENT_SOCKET_H
|
||||
|
||||
#endif
|
|
@ -1,4 +1,4 @@
|
|||
#include "packet.hpp"
|
||||
#include "sock/packet.hpp"
|
||||
|
||||
sosc::Packet::Packet() {
|
||||
this->id = 0;
|
||||
|
@ -151,8 +151,7 @@ std::string* sosc::Packet::ToString(std::string* packet) const {
|
|||
(*packet)[1] = 0x0B;
|
||||
(*packet)[6] = this->id;
|
||||
(*packet)[7] = regions.size();
|
||||
|
||||
//for(auto i = this->regions.begin(); i != this->regions.end(); ++i) {
|
||||
|
||||
for(const auto& i : this->regions) {
|
||||
if(i.size() < 0xFE)
|
||||
*packet += (char)i.size();
|
||||
|
@ -164,8 +163,7 @@ std::string* sosc::Packet::ToString(std::string* packet) const {
|
|||
*packet += net::htonv<uint32_t>(i.size());
|
||||
}
|
||||
}
|
||||
|
||||
//for(auto i = this->regions.begin(); i != this->regions.end(); ++i)
|
||||
|
||||
for(const auto& i : this->regions)
|
||||
*packet += i;
|
||||
|
|
@ -24,11 +24,15 @@ public:
|
|||
bool Close(const Packet& message);
|
||||
private:
|
||||
enum MasterToClientId {
|
||||
|
||||
kLoginResponse = 0,
|
||||
kRegisterResponse,
|
||||
kServerList
|
||||
};
|
||||
|
||||
enum ClientToMasterId {
|
||||
|
||||
kLoginRequest = 0,
|
||||
kRegisterRequest,
|
||||
kServerListRequest
|
||||
};
|
||||
|
||||
ScapeConnection sock;
|
||||
|
|
|
@ -54,5 +54,10 @@ sosc::MasterClient::MasterClient(const ScapeConnection &client) {
|
|||
}
|
||||
|
||||
bool sosc::MasterClient::Process(const db::Queries *queries) {
|
||||
|
||||
Packet pck;
|
||||
int status = this->sock.Receive(&pck);
|
||||
if(status == PCK_ERR)
|
||||
return this->Close();
|
||||
else if(status == PCK_MORE)
|
||||
return true;
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
#define SOSC_INTSOCK_H
|
||||
|
||||
#include "tcpsock.hpp"
|
||||
#include "packet.hpp"
|
||||
#include "sock/packet.hpp"
|
||||
|
||||
namespace sosc {
|
||||
class IntraClient {
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#include <queue>
|
||||
#include "crypto/sha1.hpp"
|
||||
#include "crypto/base64.hpp"
|
||||
#include "sock/packet.hpp"
|
||||
#include "frame.hpp"
|
||||
#include "packet.hpp"
|
||||
#include "tcpsock.hpp"
|
||||
|
||||
#define SOSC_SHAKE_ERR (-1)
|
||||
|
|
Loading…
Reference in a new issue