summaryrefslogtreecommitdiffstats
path: root/src/ThreadNetwork.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-19 17:20:51 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-19 17:20:51 +0200
commitf24107368fa47f911f4491f644ff3755525c91e1 (patch)
tree02dc3583ed82d81139b17191af9a9bfae40c45a9 /src/ThreadNetwork.cpp
parent2017-08-18 (diff)
downloadAltCraft-f24107368fa47f911f4491f644ff3755525c91e1.tar
AltCraft-f24107368fa47f911f4491f644ff3755525c91e1.tar.gz
AltCraft-f24107368fa47f911f4491f644ff3755525c91e1.tar.bz2
AltCraft-f24107368fa47f911f4491f644ff3755525c91e1.tar.lz
AltCraft-f24107368fa47f911f4491f644ff3755525c91e1.tar.xz
AltCraft-f24107368fa47f911f4491f644ff3755525c91e1.tar.zst
AltCraft-f24107368fa47f911f4491f644ff3755525c91e1.zip
Diffstat (limited to 'src/ThreadNetwork.cpp')
-rw-r--r--src/ThreadNetwork.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/ThreadNetwork.cpp b/src/ThreadNetwork.cpp
index f734c0c..5a8a61a 100644
--- a/src/ThreadNetwork.cpp
+++ b/src/ThreadNetwork.cpp
@@ -25,7 +25,7 @@ void ThreadNetwork::Execute() {
LOG(INFO) << "Connecting to server";
EventAgregator::PushEvent(EventType::Connecting, ConnectingData{});
try {
- nc = new NetworkClient(data.address, data.port, "HelloOne");
+ nc = std::make_shared<NetworkClient>(data.address, data.port, "HelloOne");
} catch (std::exception &e) {
LOG(WARNING) << "Connection failed";
EventAgregator::PushEvent(EventType::ConnectionFailed, ConnectionFailedData{e.what()});
@@ -39,8 +39,7 @@ void ThreadNetwork::Execute() {
auto data = std::get<DisconnectData>(eventData);
EventAgregator::PushEvent(EventType::Disconnected, DisconnectedData{ data.reason });
LOG(INFO) << "Disconnected: " << data.reason;
- delete nc;
- nc = nullptr;
+ nc.reset();
});
listener.RegisterHandler(EventType::NetworkClientException, [this](EventData eventData) {
@@ -54,5 +53,5 @@ void ThreadNetwork::Execute() {
timer.Update();
}
- delete nc;
+ nc.reset();
} \ No newline at end of file