summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander Harkness <me@bearbin.net>2017-09-08 09:36:23 +0200
committerMattes D <github@xoft.cz>2017-09-08 09:36:23 +0200
commitc334824199fcddde9f5a712a08a54db798965890 (patch)
tree0189f070eacb54e5c19dd2a2903c37d812d7887e /src
parentMade world data paths adjustable, and added API to temporarily disable saving chunks to disk. (#3912) (diff)
downloadcuberite-c334824199fcddde9f5a712a08a54db798965890.tar
cuberite-c334824199fcddde9f5a712a08a54db798965890.tar.gz
cuberite-c334824199fcddde9f5a712a08a54db798965890.tar.bz2
cuberite-c334824199fcddde9f5a712a08a54db798965890.tar.lz
cuberite-c334824199fcddde9f5a712a08a54db798965890.tar.xz
cuberite-c334824199fcddde9f5a712a08a54db798965890.tar.zst
cuberite-c334824199fcddde9f5a712a08a54db798965890.zip
Diffstat (limited to 'src')
-rw-r--r--src/ClientHandle.cpp14
-rw-r--r--src/ClientHandle.h8
2 files changed, 11 insertions, 11 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 878f84782..f42f52cb1 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -2087,6 +2087,12 @@ void cClientHandle::Tick(float a_Dt)
return;
}
+ // If player has been kicked, terminate the connection:
+ if (m_State == csKicked)
+ {
+ m_Link->Shutdown();
+ }
+
// If destruction is queued, destroy now:
if (m_State == csQueuedForDestruction)
{
@@ -2515,6 +2521,10 @@ void cClientHandle::SendDisconnect(const AString & a_Reason)
LOGD("Sending a DC: \"%s\"", StripColorCodes(a_Reason).c_str());
m_Protocol->SendDisconnect(a_Reason);
m_HasSentDC = true;
+ // csKicked means m_Link will be shut down on the next tick. The
+ // disconnect packet data is sent in the tick thread so the connection
+ // is closed there after the data is sent.
+ m_State = csKicked;
}
}
@@ -3389,7 +3399,3 @@ void cClientHandle::OnError(int a_ErrorCode, const AString & a_ErrorMsg)
}
SocketClosed();
}
-
-
-
-
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index b1acede77..630994c2e 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -491,11 +491,10 @@ private:
csDownloadingWorld, ///< The client is waiting for chunks, we're waiting for the loader to provide and send them
csConfirmingPos, ///< The client has been sent the position packet, waiting for them to repeat the position back
csPlaying, ///< Normal gameplay
+ csKicked, ///< Disconnect packet sent, awaiting connection closure
csQueuedForDestruction, ///< The client will be destroyed in the next tick (flag set when socket closed)
csDestroying, ///< The client is being destroyed, don't queue any more packets / don't add to chunks
csDestroyed, ///< The client has been destroyed, the destructor is to be called from the owner thread
-
- // TODO: Add Kicking here as well
} ;
/* Mutex protecting m_State from concurrent writes. */
@@ -595,8 +594,3 @@ private:
virtual void OnRemoteClosed(void) override;
virtual void OnError(int a_ErrorCode, const AString & a_ErrorMsg) override;
}; // tolua_export
-
-
-
-
-