From 8a37ca2a1cb5fc5d9680769f3ec4cf9cdbf37b99 Mon Sep 17 00:00:00 2001 From: qicosmos Date: Wed, 26 Aug 2020 16:16:16 +0800 Subject: [PATCH] remove app_client --- examples/app_client/CMakeLists.txt | 13 -- examples/app_client/app_client.vcxproj | 145 ------------------ .../app_client/app_client.vcxproj.filters | 27 ---- examples/app_client/client.hpp | 89 ----------- examples/app_client/main.cpp | 56 ------- 5 files changed, 330 deletions(-) delete mode 100644 examples/app_client/CMakeLists.txt delete mode 100644 examples/app_client/app_client.vcxproj delete mode 100644 examples/app_client/app_client.vcxproj.filters delete mode 100644 examples/app_client/client.hpp delete mode 100644 examples/app_client/main.cpp diff --git a/examples/app_client/CMakeLists.txt b/examples/app_client/CMakeLists.txt deleted file mode 100644 index 63ba140..0000000 --- a/examples/app_client/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.7) -project(app_client) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -std=c++11") - -find_package(Boost COMPONENTS system REQUIRED) -include_directories( - "../../include" - "../../third/msgpack/include" -) - -add_executable(app_client main.cpp) -target_link_libraries(app_client ${Boost_LIBRARIES}) diff --git a/examples/app_client/app_client.vcxproj b/examples/app_client/app_client.vcxproj deleted file mode 100644 index 0770393..0000000 --- a/examples/app_client/app_client.vcxproj +++ /dev/null @@ -1,145 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - - - - - - - 16.0 - {9A1E8AA7-C6E1-4B8C-8208-2FC2A1E33A71} - appclient - 10.0 - - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - ..\..\include;..\..\third\msgpack\include;$(IncludePath) - - - ..\..\include;..\..\third\msgpack\include;$(IncludePath) - - - ..\..\include;..\..\third\msgpack\include;$(IncludePath) - - - ..\..\include;..\..\third\msgpack\include;$(IncludePath) - - - - Level3 - Disabled - true - true - - - Console - - - - - Level3 - Disabled - true - true - - - Console - - - - - Level3 - MaxSpeed - true - true - true - true - - - Console - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - - - Console - true - true - - - - - - \ No newline at end of file diff --git a/examples/app_client/app_client.vcxproj.filters b/examples/app_client/app_client.vcxproj.filters deleted file mode 100644 index a4a3721..0000000 --- a/examples/app_client/app_client.vcxproj.filters +++ /dev/null @@ -1,27 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - 源文件 - - - - - 头文件 - - - \ No newline at end of file diff --git a/examples/app_client/client.hpp b/examples/app_client/client.hpp deleted file mode 100644 index c9e5921..0000000 --- a/examples/app_client/client.hpp +++ /dev/null @@ -1,89 +0,0 @@ -#pragma once -#include -using namespace rest_rpc; -using namespace rest_rpc::rpc_service; - -struct person { - int id; - std::string name; - int age; - - MSGPACK_DEFINE(id, name, age); -}; - -class client { -public: - client(std::string ip, short port) : client_(std::move(ip), port) { - } - - bool connect() { - return client_.connect(); - } - - void async_connect() { - client_.async_connect(); - } - - bool wait_conn(size_t timeout) { - return client_.wait_conn(timeout); - } - - int add(int a, int b) { - try { - return client_.call("add", a, b); - } - catch (const std::exception & e) { - std::cout << e.what() << std::endl; - return -1; - } - } - - std::future async_add(int a, int b) { - return client_.async_call("add", a, b); - } - - std::string translate(const std::string& str) { - try { - return client_.call("translate", str); - } - catch (const std::exception & e) { - std::cout << e.what() << std::endl; - return ""; - } - } - - std::future async_translate(const std::string& str) { - return client_.async_call("translate", str); - } - - void hello(const std::string& str) { - try { - client_.call("hello", str); - } - catch (const std::exception & e) { - std::cout << e.what() << std::endl; - } - } - - std::string get_person_name(const person& p) { - try { - return client_.call("get_person_name", p); - } - catch (const std::exception & e) { - std::cout << e.what() << std::endl; - return ""; - } - } - - person get_person() { - try { - return client_.call("get_person"); - } - catch (const std::exception & e) { - std::cout << e.what() << std::endl; - return {}; - } - } -private: - rpc_client client_; -}; \ No newline at end of file diff --git a/examples/app_client/main.cpp b/examples/app_client/main.cpp deleted file mode 100644 index d0b95a1..0000000 --- a/examples/app_client/main.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include -#include "client.hpp" - -void test_client() { - client cl("127.0.0.1", 9000); - bool r = cl.connect(); - if (!r) { - std::cout << "connect failed" << std::endl; - return; - } - - try { - int result = cl.add(2, 3); - cl.hello("purecpp"); - auto str = cl.translate("purecpp"); - auto name = cl.get_person_name({ 1, "tom", 20 }); - auto p = cl.get_person(); - - std::cout << result << '\n'; - std::cout << str << '\n'; - std::cout << name << '\n'; - std::cout << p.name << '\n'; - - { - auto future = cl.async_add(4, 5); - if (future.wait_for(std::chrono::milliseconds(50)) == std::future_status::timeout) { - std::cout << "timeout" << std::endl; - } - else { - auto result = future.get().as(); - std::cout << result << std::endl; - } - } - - { - auto future = cl.async_translate("modern c++"); - if (future.wait_for(std::chrono::milliseconds(50)) == std::future_status::timeout) { - std::cout << "timeout" << std::endl; - } - else { - auto result = future.get().as(); - std::cout << result << std::endl; - } - } - } - catch (const std::exception& ex) { - std::cout << ex.what() << std::endl; - } -} - -int main() { - test_client(); - - std::string str; - std::cin >> str; -} \ No newline at end of file