diff options
author | Samuel Barney <sbarney@instructure.com> | 2016-07-18 22:39:11 +0200 |
---|---|---|
committer | Samuel Barney <samjbarney@gmail.com> | 2016-08-15 19:13:03 +0200 |
commit | 24e89bbb2c656224d06aed084b952bbc885e3914 (patch) | |
tree | ba75a68cce6ea868acba60ae08efeeccf003736d /src/Protocol | |
parent | Switch out long download/compile links. (#3278) (diff) | |
download | cuberite-24e89bbb2c656224d06aed084b952bbc885e3914.tar cuberite-24e89bbb2c656224d06aed084b952bbc885e3914.tar.gz cuberite-24e89bbb2c656224d06aed084b952bbc885e3914.tar.bz2 cuberite-24e89bbb2c656224d06aed084b952bbc885e3914.tar.lz cuberite-24e89bbb2c656224d06aed084b952bbc885e3914.tar.xz cuberite-24e89bbb2c656224d06aed084b952bbc885e3914.tar.zst cuberite-24e89bbb2c656224d06aed084b952bbc885e3914.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Protocol/Protocol18x.cpp | 27 | ||||
-rw-r--r-- | src/Protocol/Protocol19x.cpp | 29 |
2 files changed, 36 insertions, 20 deletions
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp index ae9571f03..efd9cd5a9 100644 --- a/src/Protocol/Protocol18x.cpp +++ b/src/Protocol/Protocol18x.cpp @@ -16,6 +16,7 @@ Implements the 1.8.x protocol classes: #include "Packetizer.h" #include "../ClientHandle.h" +#include "../ChannelManager.h" #include "../Root.h" #include "../Server.h" #include "../World.h" @@ -2483,10 +2484,24 @@ void cProtocol180::HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer) return; } - // Read the plugin message and relay to clienthandle: + // Read the rest of the message + cByteBuffer Buffer = a_ByteBuffer; AString Data; VERIFY(a_ByteBuffer.ReadString(Data, a_ByteBuffer.GetReadableSpace() - 1)); // Always succeeds - m_Client->HandlePluginMessage(Channel, Data); + + auto manager = cRoot::Get()->GetServer()->GetChannelManager(); + // Register the client on the requested channels + if (Channel == "REGISTER") + { + manager->AddClientToChannels(*m_Client, Data); + } + else if (Channel == "UNREGISTER") + { + manager->RemoveClientFromChannels(*m_Client, Data); + } + + // Call the channel message handler + manager->HandleChannelMessage(*m_Client, Channel, Buffer); } @@ -2738,10 +2753,7 @@ void cProtocol180::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const } LOG("Unhandled vanilla plugin channel: \"%s\".", a_Channel.c_str()); - // Read the payload and send it through to the clienthandle: - AString Message; - VERIFY(a_ByteBuffer.ReadString(Message, a_ByteBuffer.GetReadableSpace() - 1)); - m_Client->HandlePluginMessage(a_Channel, Message); + cRoot::Get()->GetServer()->GetChannelManager()->HandleChannelMessage(*m_Client, a_Channel, a_ByteBuffer); } @@ -3592,6 +3604,3 @@ void cProtocol180::WriteEntityProperties(cPacketizer & a_Pkt, const cEntity & a_ a_Pkt.WriteBEInt32(0); // NumProperties } - - - diff --git a/src/Protocol/Protocol19x.cpp b/src/Protocol/Protocol19x.cpp index c11e05565..a8c916e5b 100644 --- a/src/Protocol/Protocol19x.cpp +++ b/src/Protocol/Protocol19x.cpp @@ -22,6 +22,7 @@ Implements the 1.9.x protocol classes: #include "Packetizer.h" #include "../ClientHandle.h" +#include "../ChannelManager.h" #include "../Root.h" #include "../Server.h" #include "../World.h" @@ -2552,10 +2553,24 @@ void cProtocol190::HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer) return; } - // Read the plugin message and relay to clienthandle: + // Read the rest of the message + cByteBuffer Buffer = a_ByteBuffer; AString Data; VERIFY(a_ByteBuffer.ReadString(Data, a_ByteBuffer.GetReadableSpace() - 1)); // Always succeeds - m_Client->HandlePluginMessage(Channel, Data); + + auto manager = cRoot::Get()->GetServer()->GetChannelManager(); + // Register the client on the requested channels + if (Channel == "REGISTER") + { + manager->AddClientToChannels(*m_Client, Data); + } + else if (Channel == "UNREGISTER") + { + manager->RemoveClientFromChannels(*m_Client, Data); + } + + // Call the channel message handler + manager->HandleChannelMessage(*m_Client, Channel, Buffer); } @@ -2843,10 +2858,7 @@ void cProtocol190::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const } LOG("Unhandled vanilla plugin channel: \"%s\".", a_Channel.c_str()); - // Read the payload and send it through to the clienthandle: - AString Message; - VERIFY(a_ByteBuffer.ReadString(Message, a_ByteBuffer.GetReadableSpace() - 1)); - m_Client->HandlePluginMessage(a_Channel, Message); + cRoot::Get()->GetServer()->GetChannelManager()->HandleChannelMessage(*m_Client, a_Channel, a_ByteBuffer); } @@ -4381,8 +4393,3 @@ void cProtocol194::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, cons Writer.Finish(); Pkt.WriteBuf(Writer.GetResult().data(), Writer.GetResult().size()); } - - - - - |