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;">
|
<table style="margin-right: 8px; margin-bottom: 8px;">
|
||||||
<thead>
|
<thead>
|
||||||
<th colspan="100" class="center">
|
<th colspan="100" class="center">
|
||||||
ID 0: Login Attempt<br />
|
ID 0: Login Response<br />
|
||||||
Responder
|
Responder
|
||||||
</th>
|
</th>
|
||||||
</thead>
|
</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;">
|
<table style="margin-right: 8px; margin-bottom: 8px;">
|
||||||
<thead>
|
<thead>
|
||||||
<th colspan="100" class="center">
|
<th colspan="100" class="center">
|
||||||
ID 1: Registration Attempt<br />
|
ID 1: Registration Response<br />
|
||||||
Responder
|
Responder
|
||||||
</th>
|
</th>
|
||||||
</thead>
|
</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;">
|
<table style="margin-right: 8px; margin-bottom: 8px;">
|
||||||
<thead>
|
<thead>
|
||||||
<th colspan="100" class="center">
|
<th colspan="100" class="center">
|
||||||
ID 2: Server List Request<br />
|
ID 2: Server Listing<br />
|
||||||
Responder
|
Responder
|
||||||
</th>
|
</th>
|
||||||
</thead>
|
</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;">
|
<table style="margin-right: 8px; margin-bottom: 8px;">
|
||||||
<thead>
|
<thead>
|
||||||
<th colspan="100" class="center">
|
<th colspan="100" class="center">
|
||||||
ID 0: Login Attempt<br />
|
ID 0: Login Request<br />
|
||||||
Requester
|
Requester
|
||||||
</th>
|
</th>
|
||||||
</thead>
|
</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;">
|
<table style="margin-right: 8px; margin-bottom: 8px;">
|
||||||
<thead>
|
<thead>
|
||||||
<th colspan="100" class="center">
|
<th colspan="100" class="center">
|
||||||
ID 1: Registration Attempt<br />
|
ID 1: Registration Request<br />
|
||||||
Requester
|
Requester
|
||||||
</th>
|
</th>
|
||||||
</thead>
|
</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() {
|
sosc::Packet::Packet() {
|
||||||
this->id = 0;
|
this->id = 0;
|
||||||
|
@ -152,7 +152,6 @@ std::string* sosc::Packet::ToString(std::string* packet) const {
|
||||||
(*packet)[6] = this->id;
|
(*packet)[6] = this->id;
|
||||||
(*packet)[7] = regions.size();
|
(*packet)[7] = regions.size();
|
||||||
|
|
||||||
//for(auto i = this->regions.begin(); i != this->regions.end(); ++i) {
|
|
||||||
for(const auto& i : this->regions) {
|
for(const auto& i : this->regions) {
|
||||||
if(i.size() < 0xFE)
|
if(i.size() < 0xFE)
|
||||||
*packet += (char)i.size();
|
*packet += (char)i.size();
|
||||||
|
@ -165,7 +164,6 @@ std::string* sosc::Packet::ToString(std::string* packet) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//for(auto i = this->regions.begin(); i != this->regions.end(); ++i)
|
|
||||||
for(const auto& i : this->regions)
|
for(const auto& i : this->regions)
|
||||||
*packet += i;
|
*packet += i;
|
||||||
|
|
|
@ -24,11 +24,15 @@ public:
|
||||||
bool Close(const Packet& message);
|
bool Close(const Packet& message);
|
||||||
private:
|
private:
|
||||||
enum MasterToClientId {
|
enum MasterToClientId {
|
||||||
|
kLoginResponse = 0,
|
||||||
|
kRegisterResponse,
|
||||||
|
kServerList
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ClientToMasterId {
|
enum ClientToMasterId {
|
||||||
|
kLoginRequest = 0,
|
||||||
|
kRegisterRequest,
|
||||||
|
kServerListRequest
|
||||||
};
|
};
|
||||||
|
|
||||||
ScapeConnection sock;
|
ScapeConnection sock;
|
||||||
|
|
|
@ -54,5 +54,10 @@ sosc::MasterClient::MasterClient(const ScapeConnection &client) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sosc::MasterClient::Process(const db::Queries *queries) {
|
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
|
#define SOSC_INTSOCK_H
|
||||||
|
|
||||||
#include "tcpsock.hpp"
|
#include "tcpsock.hpp"
|
||||||
#include "packet.hpp"
|
#include "sock/packet.hpp"
|
||||||
|
|
||||||
namespace sosc {
|
namespace sosc {
|
||||||
class IntraClient {
|
class IntraClient {
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include "crypto/sha1.hpp"
|
#include "crypto/sha1.hpp"
|
||||||
#include "crypto/base64.hpp"
|
#include "crypto/base64.hpp"
|
||||||
|
#include "sock/packet.hpp"
|
||||||
#include "frame.hpp"
|
#include "frame.hpp"
|
||||||
#include "packet.hpp"
|
|
||||||
#include "tcpsock.hpp"
|
#include "tcpsock.hpp"
|
||||||
|
|
||||||
#define SOSC_SHAKE_ERR (-1)
|
#define SOSC_SHAKE_ERR (-1)
|
||||||
|
|
Loading…
Reference in a new issue