summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Protocol18x.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Protocol/Protocol18x.cpp')
-rw-r--r--src/Protocol/Protocol18x.cpp27
1 files changed, 18 insertions, 9 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
}
-
-
-