Before you do anything with Proton, you need a reference to ProtonManager. In your onEnable()
method, store a reference to it.
A reference to ProtonManager will allow you to use all of Proton's API.
Create an event listener for the async chat event and broadcast your custom data there. In this case, we opted for a container class which holds the player name and message.
Here we're broadcasting to the namespace networkchat
with the subject chatMessage
Here we will listen for broadcasted messages using a MessageHandler
Notice: We are listening for the same namespace and subject as we sent. We are also expecting the same datatype we sent.
We must also register our MessageHandlers with Proton. This is done through the registerMessageHandlers
method.
We're done! You will now be able to chat network-wide.