Teaspeak-Server/server/src/client/voice/VoiceClientPacketHandler.cpp
2020-03-17 12:08:07 +01:00

41 lines
1.3 KiB
C++

#include <misc/endianness.h>
#include <log/LogUtils.h>
#include "./VoiceClient.h"
using namespace std;
using namespace std::chrono;
using namespace ts::server;
using namespace ts::protocol;
//#define PKT_LOG_PING
void VoiceClient::handlePacketCommand(const pipes::buffer_view& command_string) {
{
std::lock_guard slock{this->state_lock};
if(this->state == ClientState::DISCONNECTED) return;
}
std::unique_ptr<Command> command;
command_result result{};
try {
command = make_unique<Command>(Command::parse(command_string, true, !ts::config::server::strict_ut8_mode));
} catch(std::invalid_argument& ex) {
result = command_result{error::parameter_convert, std::string{ex.what()}};
goto handle_error;
} catch(std::exception& ex) {
result = command_result{error::parameter_convert, std::string{ex.what()}};
goto handle_error;
}
if(command->command() == "clientek") {
result = this->handleCommandClientEk(*command);
if(result.error_code()) goto handle_error;
} else if(command->command() == "clientinitiv") {
result = this->handleCommandClientInitIv(*command);
if(result.error_code()) goto handle_error;
} else this->handleCommandFull(*command, true);
return;
handle_error:
this->notifyError(result);
result.release_details();
}