mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 06:27:45 +00:00
Merge pull request #415 from NotAdam/boost_scrap
zone and api work a bit better now
This commit is contained in:
commit
ac09ecfa8d
5 changed files with 419 additions and 408 deletions
|
@ -36,11 +36,11 @@ add_subdirectory( "src/common" )
|
|||
add_subdirectory( "src/servers" )
|
||||
#add_subdirectory( "src/dbm" )
|
||||
|
||||
add_subdirectory( "src/tools/exd_common_gen" )
|
||||
add_subdirectory( "src/tools/exd_struct_gen" )
|
||||
add_subdirectory( "src/tools/exd_struct_test" )
|
||||
add_subdirectory( "src/tools/quest_parser" )
|
||||
add_subdirectory( "src/tools/discovery_parser" )
|
||||
add_subdirectory( "src/tools/mob_parse" )
|
||||
#add_subdirectory( "src/tools/exd_common_gen" )
|
||||
#add_subdirectory( "src/tools/exd_struct_gen" )
|
||||
#add_subdirectory( "src/tools/exd_struct_test" )
|
||||
#add_subdirectory( "src/tools/quest_parser" )
|
||||
#add_subdirectory( "src/tools/discovery_parser" )
|
||||
#add_subdirectory( "src/tools/mob_parse" )
|
||||
#add_subdirectory("src/tools/pcb_reader")
|
||||
#add_subdirectory("src/tools/event_object_parser")
|
||||
|
|
|
@ -487,7 +487,12 @@ void checkSession( shared_ptr< HttpServer::Response > response, shared_ptr< Http
|
|||
}
|
||||
else
|
||||
{
|
||||
std::string json_string = "{\"result\":\"" + std::to_string( result ) + "\"}";
|
||||
std::string json_string = nlohmann::json( {
|
||||
{ "result", result },
|
||||
{ "result2", "penis" },
|
||||
{ "result3", "wtf" }
|
||||
} ).dump()
|
||||
;
|
||||
*response << buildHttpResponse( 200, json_string, JSON );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ Core::LobbySessionPtr Core::Network::RestConnector::getSession( char* sId )
|
|||
|
||||
try
|
||||
{
|
||||
json.parse( content );
|
||||
json = json.parse( content );
|
||||
}
|
||||
catch( std::exception& e )
|
||||
{
|
||||
|
@ -99,7 +99,7 @@ bool Core::Network::RestConnector::checkNameTaken( std::string name )
|
|||
|
||||
try
|
||||
{
|
||||
json.parse( content );
|
||||
json = json.parse( content );
|
||||
}
|
||||
catch( std::exception& e )
|
||||
{
|
||||
|
@ -133,7 +133,7 @@ uint32_t Core::Network::RestConnector::getNextCharId()
|
|||
|
||||
try
|
||||
{
|
||||
json.parse( content );
|
||||
json = json.parse( content );
|
||||
}
|
||||
catch( std::exception& e )
|
||||
{
|
||||
|
@ -172,7 +172,7 @@ uint64_t Core::Network::RestConnector::getNextContentId()
|
|||
|
||||
try
|
||||
{
|
||||
json.parse( content );
|
||||
json = json.parse( content );
|
||||
}
|
||||
catch( std::exception& e )
|
||||
{
|
||||
|
@ -213,7 +213,7 @@ CharList Core::Network::RestConnector::getCharList( char* sId )
|
|||
|
||||
try
|
||||
{
|
||||
json.parse( content );
|
||||
json = json.parse( content );
|
||||
}
|
||||
catch( std::exception& e )
|
||||
{
|
||||
|
@ -230,10 +230,11 @@ CharList Core::Network::RestConnector::getCharList( char* sId )
|
|||
{
|
||||
g_log.debug( child["contentId"] );
|
||||
//std::string, uint32_t, uint64_t, std::string
|
||||
list.push_back( std::make_tuple( child["name"].get< std::string >() ),
|
||||
list.push_back( { child["name"].get< std::string >(),
|
||||
child["charId"].get< uint32_t >(),
|
||||
child["contentId"].get< uint64_t >(),
|
||||
child["infoJson"].get< std::string >() );
|
||||
child["infoJson"].get< std::string >()
|
||||
} );
|
||||
}
|
||||
|
||||
return list;
|
||||
|
@ -266,7 +267,7 @@ bool Core::Network::RestConnector::deleteCharacter( char* sId, std::string name
|
|||
auto json = nlohmann::json();
|
||||
try
|
||||
{
|
||||
json.parse( content );
|
||||
json = json.parse( content );
|
||||
}
|
||||
catch( std::exception& e )
|
||||
{
|
||||
|
@ -303,7 +304,7 @@ int Core::Network::RestConnector::createCharacter( char* sId, std::string name,
|
|||
|
||||
try
|
||||
{
|
||||
json.parse( content );
|
||||
json = json.parse( content );
|
||||
}
|
||||
catch( std::exception& e )
|
||||
{
|
||||
|
|
|
@ -4,12 +4,15 @@
|
|||
#include <asio.hpp>
|
||||
|
||||
#include <Util/Util.h>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
#include <random>
|
||||
#include <mutex>
|
||||
#include <type_traits>
|
||||
#include <functional>
|
||||
|
||||
#ifndef CASE_INSENSITIVE_EQUALS_AND_HASH
|
||||
#define CASE_INSENSITIVE_EQUALS_AND_HASH
|
||||
|
||||
class case_insensitive_equals {
|
||||
public:
|
||||
|
@ -19,13 +22,15 @@ public:
|
|||
};
|
||||
class case_insensitive_hash {
|
||||
public:
|
||||
size_t operator()( const std::string &key ) const {
|
||||
size_t operator()( const std::string &key ) const
|
||||
{
|
||||
std::size_t seed=0;
|
||||
for( auto &c : key )
|
||||
Core::Util::hashCombine< char >( seed, std::tolower( c ) );
|
||||
return seed;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
namespace SimpleWeb {
|
||||
template <class socket_type>
|
||||
|
@ -204,11 +209,11 @@ namespace SimpleWeb {
|
|||
|
||||
virtual void connect()=0;
|
||||
|
||||
std::shared_ptr< asio::deadline_timer > get_timeout_timer() {
|
||||
std::shared_ptr< asio::basic_waitable_timer< std::chrono::steady_clock > > get_timeout_timer() {
|
||||
if(config.timeout==0)
|
||||
return nullptr;
|
||||
|
||||
auto timer = std::make_shared< asio::deadline_timer >( io_service );
|
||||
auto timer=std::make_shared< asio::basic_waitable_timer< std::chrono::steady_clock > >(io_service);
|
||||
timer->expires_from_now( std::chrono::seconds( config.timeout ) );
|
||||
timer->async_wait([this](const std::error_code& ec) {
|
||||
if(!ec) {
|
||||
|
@ -265,7 +270,7 @@ namespace SimpleWeb {
|
|||
if(content_length>num_additional_bytes) {
|
||||
auto timer=get_timeout_timer();
|
||||
asio::async_read(*socket, response->content_buffer,
|
||||
asio::transfer_exactly( static_cast< size_t >( content_length - num_additional_bytes ) ),
|
||||
asio::transfer_exactly(content_length-num_additional_bytes),
|
||||
[this, timer](const std::error_code& ec, size_t /*bytes_transferred*/) {
|
||||
if(timer)
|
||||
timer->cancel();
|
||||
|
@ -306,7 +311,7 @@ namespace SimpleWeb {
|
|||
line.pop_back();
|
||||
std::streamsize length=stol(line, 0, 16);
|
||||
|
||||
auto num_additional_bytes = response->content_buffer.size() - bytes_transferred;
|
||||
auto num_additional_bytes=static_cast<std::streamsize>(response->content_buffer.size()-bytes_transferred);
|
||||
|
||||
auto post_process=[this, &response, &streambuf, length] {
|
||||
std::ostream stream(&streambuf);
|
||||
|
@ -331,7 +336,7 @@ namespace SimpleWeb {
|
|||
if((2+length)>num_additional_bytes) {
|
||||
auto timer=get_timeout_timer();
|
||||
asio::async_read(*socket, response->content_buffer,
|
||||
asio::transfer_exactly( static_cast< size_t >( 2 + length - num_additional_bytes ) ),
|
||||
asio::transfer_exactly(2+length-num_additional_bytes),
|
||||
[this, post_process, timer](const std::error_code& ec, size_t /*bytes_transferred*/) {
|
||||
if(timer)
|
||||
timer->cancel();
|
||||
|
|
Loading…
Add table
Reference in a new issue