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 shared environment, sending message works sometimes.

I'm working on shared environment, and I have succeeded in sending message from user a to b. now I'm trying to send vectors that change the position of a gameobject, for instance person a moves a cube, person b sees the movement. This is currently not working for me. The message is send but is not received. I tested this heavily. I use the microsoft Hololens academy shared environment library.

I will post a code sample that works. And after that a code sample that is currently not working. Working code:

First I subscribe the callback method to the messageID with:

protected override void Start()
{
base.Start();
CustomMessages.Instance.MessageHandlers[CustomMessages.TestMessageID.StartMachine] = this.startMachine;
}
The subscribed method:

private void startMachine(NetworkInMessage msg)
{
// do something
Act();
}
this method is called when a button is pressed, which in turn broadcasts this information by calling a method on a static class.

protected override void PerformManipulationStart(Vector3 position)
{
//broadcasting message
CustomMessages.Instance.SendStartMachine();
//the below statement is some local action
MachineMovement.Instance.StartMachine();
}
The method that broadcasts

public void SendStartMachine()
{
// If we are connected to a session, broadcast our head info
if (this.serverConnection != null && this.serverConnection.IsConnected())
{
// Create an outgoing network message to contain all the info we want to send
NetworkOutMessage msg = CreateMessage((byte)TestMessageID.StartMachine);

    // Send the message as a broadcast, which will cause the server to forward it to all other users in the session.
    this.serverConnection.Broadcast(
        msg,
        MessagePriority.Immediate,
        MessageReliability.Reliable,
        MessageChannel.Avatar);
}

}
I found an error before in the testmessage enum. If you put something below max then the message will not be broadcasted. I placed the UpdateMachinePosition on several locations but it's still not called. All other testmessage ID's work.

public enum TestMessageID : byte
{
HeadTransform = MessageID.UserMessageIDStart,
UserAvatar,
UserHit,
ShootProjectile,
StageTransform,
ResetStage,
ExplodeTarget,
StartMachine,
UpdateMachinePosition,
StopMachine,
Alarm,
Mash,
Max
}
So here is the code of the class where the broadcast is sent but not received. If one moves an gameobject. The change is not received on the other Hololenses.

Subscribing the method to the messageID:

protected override void Start() {
base.Start();
rb = GetComponent();
//subscribed in the line below.
CustomMessages.Instance.MessageHandlers[CustomMessages.TestMessageID.UpdateMachinePosition] = this.RemoteMachinePosition;
}
The subscibed method, currently just using destroy to test if something happens, destroy has been seperately tested and works:

void RemoteMachinePosition(NetworkInMessage msg)
{
Destroy(totransform.gameObject);

}
The method doing something when called locally. Again I have tested several times that the message is being send:

public override void performAction()
{
// 4.a: Calculate the moveVector as position - manipulationPreviousPosition.
moveVector = (ManipulationManager.Instance.ManipulationPosition - manipulationPreviousPosition) *2;

    // 4.a: Update the manipulationPreviousPosition with the current position.
    manipulationPreviousPosition = ManipulationManager.Instance.ManipulationPosition;

    // 4.a: Increment this transform's position by the moveVector.
    totransform.position += moveVector;
    // calling custommessage class to broadcast.
    CustomMessages.Instance.SendMachineTransform(moveVector, name);

}
The method called on the custommessage class:

public void SendMachineTransform(Vector3 Movement, string Name)
{
// If we are connected to a session, broadcast our head info
if (this.serverConnection != null && this.serverConnection.IsConnected())
{
// Create an outgoing network message to contain all the info we want to send
NetworkOutMessage msg = CreateMessage((byte)TestMessageID.UpdateMachinePosition);

    // Send the message as a broadcast, which will cause the server to forward it to all other users in the session.
    this.serverConnection.Broadcast(
        msg,
        MessagePriority.Immediate,
        MessageReliability.Reliable,
        MessageChannel.Avatar);
}

}
All suggestions are welcome

Answers

  • Options

    Updating every manipulation may be too much. We update once the host completes the manipulation. So in a shared session if the host makes HoloMaps bigger or rotates/etc. Once they stop their manipulation or navigation gesture it sends the update. Would that work for you?

    Otherwise perhaps you could throttle a bit and only send an update every X updates (to be determined by testing what works).

    Taqtile

Sign In or Register to comment.