Custom Messages |
Last Updated: 22/03/2019
This topic contains the following sections:
You can specify a list of custom messages that you are using in your scene. When you build your scene, we create a meta-data file that lists the custom messages that you have specified. This is then used by our backend services to forward your messages to the correct users.
Find the App object in your scene and add the CustomMessageList component if it is not already there.
Edit the CustomMessageList_customMessages array field and add a new entry.
Add a valid name for your message.
Optionally add a description for your message.
Give the message a unique "type". This is a unique number greater than or equal to 1000.
Update the profile to indicate who can send this message: Participant means anybody can send it, and Space Owner means only the Space Owner can send it.
You can also specify whether you want the message to be persisted or not, and whether the sender also receives it or not.
Note:
This MessageList is converted to meta data that the backend systems will parse to allow your message to be used.
Once you have registered the message, you can start using it.
To receive a message, you need to register with the CustomMessageManager.
// Register custom message handler for message type 1001 var customMessageManager = SingletonManager.Get < CustomMessageManager > (); customMessageManager.RegisterCustomMessageCallback( 1001, HandleCustomMessage);
To send a message, you need to use CustomMessageManager as well.
// Store the value in a byte array, so we can send it in a message byte[] payload = System.BitConverter.GetBytes( ... ); // Send the message var customMessageManager = SingletonManager.Get < CustomMessageManager > (); customMessageManager.SendCustomMessage( 1001, payload);
We have added an example scene called ExampleCustomMessage. You can look at that as an example.
As always, if you have any questions or feedback, please don't hesitate to contact us at Email support