Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.
Options

Hololens Sharing using custom message

edited October 2016 in Questions And Answers

Thank for the Holograms 240 tutorial that I am able to share the hologram between devices using hologram (energyhub) and code in this example. To take my understanding a bit further with sharing interaction of user, I modify the CustomMesages and public class ProjectileLauncher to see if my understanding is correct. Here is what I did
Add one more message type to TestMessageID enum called "test"


public enum TestMessageID : byte
    {
        ...
        Test
    }

Replicate function SendShootProjectile() and called it SendShootProjectileTest()

public void SendShootProjectileTest(Vector3 position, Vector3 direction)
    {
             //Everything is the same as in SendShootProjecttile() function
             ...
            // Instead of create mesage using TestMessageID.ShootProjectile, I used             TestMessageID.Test to test
            // Create an outgoing network message to contain all the info we want to send
            NetworkOutMessage msg = CreateMessage((byte)TestMessageID.Test);

           // Same as  s in SendShootProjecttile() function
           ...
    }

Now in ProjectileLauncher.cs I modify two things
a. Instead of:

CustomMessages.Instance.MessageHandlers[CustomMessages.TestMessageID.ShootProjectile] = this.ProcessRemoteProjectile;

I change to this:

CustomMessages.Instance.MessageHandlers[CustomMessages.TestMessageID.Test] = this.ProcessRemoteProjectile;

b. Under function SpawnProjectile() inside ProjectileLauncher.cs, instead of calling

CustomMessages.Instance.SendShootProjectile(anchor.InverseTransformPoint(ProjectilePosition), anchor.InverseTransformDirection(ProjectileDirection));

I call this:

CustomMessages.Instance.SendShootProjectileTest(anchor.InverseTransformPoint(ProjectilePosition), anchor.InverseTransformDirection(ProjectileDirection));

I then build and deploy the app to devices, the anchor sharing work ok but when the user tap to send out shoot projectile, using debug, I see the message of type "test" are broadcast under SendShootProjectileTest() function of file CustomMessages.cs, but the message is not received by other devices. I place a break point in function ProcessRemoteProjectile() in ProjectileLauncher.cs and don't see it hit.

If I get rid of all the above changes, and I run the app on devices, I see it the message type "ShootProjectile" are broadcast and then received by other devices.

I thought this whole process is simple and really straight forward, it should work but it not.
Do I miss anything?
Thank you for any help.

Comments

  • Options

    Further testing give me the result that if you add a new MessageID won't work but if you modify the existing MessageID such as "ShootProjectile" to "ShootProjectileTest" then it works. It is kind of weird

  • Options

    Well, finally I think I know the reason. Don't add new message ID below "Max" but do add new message ID above it if you need a new message.

  • Options

    Hi,

    Thanks man, this helped a lot.

    Regards,
    Pranav

  • Options

    Hi,
    Thank you, your post saves life even after 2 years!

    Kind Regards,
    Selin

  • Options

    glad it helps.

Sign In or Register to comment.