diff options
Diffstat (limited to 'src/input_common/udp/client.cpp')
| -rw-r--r-- | src/input_common/udp/client.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp index 5f5a9989c..2228571a6 100644 --- a/src/input_common/udp/client.cpp +++ b/src/input_common/udp/client.cpp | |||
| @@ -14,7 +14,6 @@ | |||
| 14 | #include "input_common/udp/client.h" | 14 | #include "input_common/udp/client.h" |
| 15 | #include "input_common/udp/protocol.h" | 15 | #include "input_common/udp/protocol.h" |
| 16 | 16 | ||
| 17 | using boost::asio::ip::address_v4; | ||
| 18 | using boost::asio::ip::udp; | 17 | using boost::asio::ip::udp; |
| 19 | 18 | ||
| 20 | namespace InputCommon::CemuhookUDP { | 19 | namespace InputCommon::CemuhookUDP { |
| @@ -31,10 +30,10 @@ public: | |||
| 31 | 30 | ||
| 32 | explicit Socket(const std::string& host, u16 port, u8 pad_index, u32 client_id, | 31 | explicit Socket(const std::string& host, u16 port, u8 pad_index, u32 client_id, |
| 33 | SocketCallback callback) | 32 | SocketCallback callback) |
| 34 | : client_id(client_id), timer(io_service), | 33 | : callback(std::move(callback)), timer(io_service), |
| 35 | send_endpoint(udp::endpoint(address_v4::from_string(host), port)), | 34 | socket(io_service, udp::endpoint(udp::v4(), 0)), client_id(client_id), |
| 36 | socket(io_service, udp::endpoint(udp::v4(), 0)), pad_index(pad_index), | 35 | pad_index(pad_index), |
| 37 | callback(std::move(callback)) {} | 36 | send_endpoint(udp::endpoint(boost::asio::ip::make_address_v4(host), port)) {} |
| 38 | 37 | ||
| 39 | void Stop() { | 38 | void Stop() { |
| 40 | io_service.stop(); | 39 | io_service.stop(); |
| @@ -126,7 +125,7 @@ static void SocketLoop(Socket* socket) { | |||
| 126 | 125 | ||
| 127 | Client::Client(std::shared_ptr<DeviceStatus> status, const std::string& host, u16 port, | 126 | Client::Client(std::shared_ptr<DeviceStatus> status, const std::string& host, u16 port, |
| 128 | u8 pad_index, u32 client_id) | 127 | u8 pad_index, u32 client_id) |
| 129 | : status(status) { | 128 | : status(std::move(status)) { |
| 130 | StartCommunication(host, port, pad_index, client_id); | 129 | StartCommunication(host, port, pad_index, client_id); |
| 131 | } | 130 | } |
| 132 | 131 | ||
| @@ -207,7 +206,7 @@ void TestCommunication(const std::string& host, u16 port, u8 pad_index, u32 clie | |||
| 207 | Common::Event success_event; | 206 | Common::Event success_event; |
| 208 | SocketCallback callback{[](Response::Version version) {}, [](Response::PortInfo info) {}, | 207 | SocketCallback callback{[](Response::Version version) {}, [](Response::PortInfo info) {}, |
| 209 | [&](Response::PadData data) { success_event.Set(); }}; | 208 | [&](Response::PadData data) { success_event.Set(); }}; |
| 210 | Socket socket{host, port, pad_index, client_id, callback}; | 209 | Socket socket{host, port, pad_index, client_id, std::move(callback)}; |
| 211 | std::thread worker_thread{SocketLoop, &socket}; | 210 | std::thread worker_thread{SocketLoop, &socket}; |
| 212 | bool result = success_event.WaitFor(std::chrono::seconds(8)); | 211 | bool result = success_event.WaitFor(std::chrono::seconds(8)); |
| 213 | socket.Stop(); | 212 | socket.Stop(); |
| @@ -267,7 +266,7 @@ CalibrationConfigurationJob::CalibrationConfigurationJob( | |||
| 267 | complete_event.Set(); | 266 | complete_event.Set(); |
| 268 | } | 267 | } |
| 269 | }}; | 268 | }}; |
| 270 | Socket socket{host, port, pad_index, client_id, callback}; | 269 | Socket socket{host, port, pad_index, client_id, std::move(callback)}; |
| 271 | std::thread worker_thread{SocketLoop, &socket}; | 270 | std::thread worker_thread{SocketLoop, &socket}; |
| 272 | complete_event.Wait(); | 271 | complete_event.Wait(); |
| 273 | socket.Stop(); | 272 | socket.Stop(); |