diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-03-08 17:37:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-08 17:37:36 +0100 |
commit | 01a4e696b3d2c973cdd1fb4345d747bd10e93ad9 (patch) | |
tree | 92996aef85fca3306b26535fa44feb812deb050b /src/Protocol/ProtocolRecognizer.h | |
parent | Some emplace_back replacements (#5149) (diff) | |
download | cuberite-01a4e696b3d2c973cdd1fb4345d747bd10e93ad9.tar cuberite-01a4e696b3d2c973cdd1fb4345d747bd10e93ad9.tar.gz cuberite-01a4e696b3d2c973cdd1fb4345d747bd10e93ad9.tar.bz2 cuberite-01a4e696b3d2c973cdd1fb4345d747bd10e93ad9.tar.lz cuberite-01a4e696b3d2c973cdd1fb4345d747bd10e93ad9.tar.xz cuberite-01a4e696b3d2c973cdd1fb4345d747bd10e93ad9.tar.zst cuberite-01a4e696b3d2c973cdd1fb4345d747bd10e93ad9.zip |
Diffstat (limited to 'src/Protocol/ProtocolRecognizer.h')
-rw-r--r-- | src/Protocol/ProtocolRecognizer.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index 56d5645c0..03b379f17 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -19,6 +19,9 @@ protocol version instance and redirects everything to it. */ class cMultiVersionProtocol { + // Work around the style checker complaining about && in template. + using OwnedContiguousByteBuffer = ContiguousByteBuffer &&; + public: cMultiVersionProtocol(); @@ -39,7 +42,7 @@ public: } /** The function that's responsible for processing incoming protocol data. */ - std::function<void(cClientHandle &, std::string_view)> HandleIncomingData; + std::function<void(cClientHandle &, OwnedContiguousByteBuffer)> HandleIncomingData; /** Sends a disconnect to the client as a result of a recognition error. This function can be used to disconnect before any protocol has been recognised. */ @@ -50,14 +53,14 @@ private: /** Handles data reception in a newly-created client handle that doesn't yet have a known protocol. a_Data contains a view of data that were just received. Tries to recognize a protocol, populate m_Protocol, and transitions to another mode depending on success. */ - void HandleIncomingDataInRecognitionStage(cClientHandle & a_Client, std::string_view a_Data); + void HandleIncomingDataInRecognitionStage(cClientHandle & a_Client, ContiguousByteBuffer && a_Data); /** Handles and responds to unsupported clients sending pings. */ - void HandleIncomingDataInOldPingResponseStage(cClientHandle & a_Client, std::string_view a_Data); + void HandleIncomingDataInOldPingResponseStage(cClientHandle & a_Client, ContiguousByteBufferView a_Data); /** Tries to recognize a protocol in the lengthed family (1.7+), based on m_Buffer. Returns a cProtocol_XXX instance if recognized. */ - std::unique_ptr<cProtocol> TryRecognizeLengthedProtocol(cClientHandle & a_Client, std::string_view a_Data); + std::unique_ptr<cProtocol> TryRecognizeLengthedProtocol(cClientHandle & a_Client); /** Sends one packet inside a cByteBuffer. This is used only when handling an outdated server ping. */ |