smol changes in a lorg world
This commit is contained in:
parent
b772a4f91f
commit
786fbfd79f
6 changed files with 14 additions and 12 deletions
|
@ -178,9 +178,8 @@ std::string* sosc::Packet::ToString(std::string* packet) const {
|
|||
|
||||
for(const auto& i : this->regions)
|
||||
*packet += i;
|
||||
|
||||
packet->assign(net::htonv<uint32_t>(packet->length()), 2, 4);
|
||||
|
||||
|
||||
packet->replace(2, 4, net::htonv<uint32_t>(packet->length()));
|
||||
return packet;
|
||||
}
|
||||
|
||||
|
|
|
@ -131,12 +131,12 @@ bool sosc::MasterClient::ProcessLogin(Packet &pck) {
|
|||
bool sosc::MasterClient::LoginError(uint16_t error_code) {
|
||||
if(++this->auth_attempts < MAX_AUTH_ATTEMPTS) {
|
||||
this->sock.Send(
|
||||
Packet(kLoginResponse, {"\0", HTONUS(error_code)})
|
||||
Packet(kLoginResponse, {std::string(1, '\0'), HTONUS(error_code)})
|
||||
);
|
||||
return true;
|
||||
} else {
|
||||
return this->Close(
|
||||
Packet(kLoginResponse, {"\0", HTONUS(0x100)})
|
||||
Packet(kLoginResponse, {std::string(1, '\0'), HTONUS(0x100)})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ bool sosc::MasterClient::ProcessRegistration(Packet &pck) {
|
|||
|
||||
bool sosc::MasterClient::RegistrationError(uint16_t error_code) {
|
||||
this->sock.Send(
|
||||
Packet(kRegisterResponse, {"\0", HTONUS(error_code)})
|
||||
Packet(kRegisterResponse, {std::string(1, '\0'), HTONUS(error_code)})
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
#include <cstdint>
|
||||
#include "utils/net.hpp"
|
||||
|
||||
#define FRAME_OK 0
|
||||
#define FRAME_MORE 1
|
||||
#define FRAME_ERR -1
|
||||
#define FRAME_OK 0
|
||||
#define FRAME_MORE 1
|
||||
#define FRAME_ERR (-1)
|
||||
|
||||
namespace sosc {
|
||||
namespace ws {
|
||||
|
|
|
@ -237,7 +237,6 @@ int Pool<T,U>::Stack::ClientCount() {
|
|||
|
||||
template<class T, class U>
|
||||
void Pool<T,U>::Stack::StackThread() {
|
||||
|
||||
while(this->is_running) {
|
||||
for(auto client = this->clients.begin();
|
||||
client != this->clients.end();
|
||||
|
@ -255,6 +254,9 @@ void Pool<T,U>::Stack::StackThread() {
|
|||
}
|
||||
this->clients_mtx.unlock();
|
||||
}
|
||||
|
||||
// TODO figure out a signal based system to avoid this
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(5));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -115,8 +115,7 @@ bool sosc::ScapeConnection::Send(const Packet& packet) {
|
|||
|
||||
std::string packet_raw;
|
||||
packet.ToString(&packet_raw);
|
||||
|
||||
return this->client.Send(packet_raw);
|
||||
return this->client.Send(ws::Frame(packet_raw));
|
||||
}
|
||||
|
||||
/******************************/
|
||||
|
|
|
@ -131,6 +131,8 @@ function pack(id, regions) {
|
|||
}
|
||||
|
||||
function unpack(data) {
|
||||
console.log(data);
|
||||
console.log(typeof data);
|
||||
if(!data.subarray(0, 2).every((v, i) => v === MAHOU[i]))
|
||||
return null;
|
||||
|
||||
|
|
Loading…
Reference in a new issue