Click or drag to resize

Custom Messages

Last Updated: 22/03/2019

Prerequisites
Create your scene and the App object.
What is Custom Messages?
Custom Messages is an advanced feature that allows you to synchronise data (using our backend services) between all users in a session. You can send you own message payload.

How does Custom Messages work?

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.

How to register a new Custom Message type

Add the message descriptor

  1. Find the App object in your scene and add the CustomMessageList component if it is not already there.

  2. Edit the CustomMessageList._customMessages array field and add a new entry.

  3. Add a valid name for your message.

  4. Optionally add a description for your message.

  5. Give the message a unique "type". This is a unique number greater than or equal to 1000.

  6. 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.

  7. 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.

Using A Custom Message

Sending and Receiving A Custom Message

  1. 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);

  2. 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);

Other Help And Information
  1. We have added an example scene called ExampleCustomMessage. You can look at that as an example.

  2. As always, if you have any questions or feedback, please don't hesitate to contact us at Email support