public void InteractResponseMessageClear() { InteractResponseMessage originalMessage = new InteractResponseMessage(); originalMessage.RequestMessageId = 1; originalMessage.FailureCode = 2; originalMessage.InteractionFragment.InteractionName = "TestInteractionName"; originalMessage.InteractionFragment.SourceParticipantId = Guid.NewGuid(); originalMessage.InteractionFragment.SourceObjectId = Guid.NewGuid(); originalMessage.InteractionFragment.TargetParticipantId = Guid.NewGuid(); originalMessage.InteractionFragment.TargetObjectId = Guid.NewGuid(); originalMessage.InteractionFragment.ExtensionDialect = "TEST"; originalMessage.SetPayloadData(UTF8Encoding.UTF8.GetBytes( "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890")); originalMessage.Clear(); InteractResponseMessage emptyMessage = new InteractResponseMessage(); emptyMessage.MessageId = originalMessage.MessageId; Assert.AreEqual(originalMessage.ToString(), emptyMessage.ToString()); }
public void InteractResponseMessageThreeFrameEncoding() { InteractResponseMessage originalMessage = new InteractResponseMessage(); originalMessage.RequestMessageId = 1; originalMessage.FailureCode = 2; originalMessage.InteractionFragment.InteractionName = "TestInteractionName"; originalMessage.InteractionFragment.SourceParticipantId = Guid.NewGuid(); originalMessage.InteractionFragment.SourceObjectId = Guid.NewGuid(); originalMessage.InteractionFragment.TargetParticipantId = Guid.NewGuid(); originalMessage.InteractionFragment.TargetObjectId = Guid.NewGuid(); originalMessage.InteractionFragment.ExtensionDialect = "TEST"; originalMessage.SetPayloadData(UTF8Encoding.UTF8.GetBytes( "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890")); byte[] encodedBytes = new byte[MxpConstants.MaxPacketSize]; Assert.AreEqual(originalMessage.FrameCount, 3); Assert.AreEqual(originalMessage.FrameDataSize(0), 255); Assert.AreEqual(originalMessage.FrameDataSize(1), 255); Assert.AreEqual(originalMessage.FrameDataSize(2), 89); int currentIndex = originalMessage.EncodeFrameData(0, encodedBytes, 0); currentIndex = originalMessage.EncodeFrameData(1, encodedBytes, currentIndex); currentIndex = originalMessage.EncodeFrameData(2, encodedBytes, currentIndex); InteractResponseMessage decodedMessage = new InteractResponseMessage(); int currentDecodeIndex = decodedMessage.DecodeFrameData(0, encodedBytes, 0, originalMessage.FrameDataSize(0)); currentDecodeIndex = decodedMessage.DecodeFrameData(1, encodedBytes, currentDecodeIndex, originalMessage.FrameDataSize(1)); currentDecodeIndex = decodedMessage.DecodeFrameData(2, encodedBytes, currentDecodeIndex, originalMessage.FrameDataSize(2)); decodedMessage.MessageId = originalMessage.MessageId; String originalMessageString = originalMessage.ToString(); String decodedMessageString = decodedMessage.ToString(); Assert.AreEqual(originalMessageString, decodedMessageString); }
public void OnInteractResponse(InteractResponseMessage responseMessage) { if ("TypeList".Equals(responseMessage.InteractionFragment.InteractionName)) { OmTypeListResponseExt omTypeListResponse = responseMessage.GetExtension <OmTypeListResponseExt>(); List <DeckObjectType> objectTypes = new List <DeckObjectType>(); foreach (OmObjectType omObjectType in omTypeListResponse.ObjectType) { DeckObjectType deckObjectType = new DeckObjectType { TypeId = new Guid(omObjectType.TypeId), TypeName = omObjectType.TypeName }; objectTypes.Add(deckObjectType); } DeckProgram.DeckDaemon.SetObjectTypes(objectTypes); } }
public void SendInteractResponse(InteractResponseMessage interactResponse) { client.Send(interactResponse); }
private void LoadReferenceMessages() { udpClient = new UdpClient(UdpClientPort); // Control messages { AcknowledgeMessage originalMessage = new AcknowledgeMessage(); originalMessage.MessageId = 1; originalMessage.AddPacketId(1); originalMessage.AddPacketId(2); originalMessage.AddPacketId(3); originalMessage.AddPacketId(4); originalMessage.AddPacketId(5); SerializeReferenceMessage(originalMessage); } { AttachRequestMessage originalMessage = new AttachRequestMessage(); originalMessage.MessageId = 1; originalMessage.TargetBubbleId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.SourceBubbleFragment.BubbleId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.SourceBubbleFragment.BubbleName = "TestBubble1"; originalMessage.SourceBubbleFragment.BubbleAssetCacheUrl = "TestCloudUrl"; originalMessage.SourceBubbleFragment.BubbleAddress = "TestBubbleAddress"; originalMessage.SourceBubbleFragment.BubblePort = 1; originalMessage.SourceBubbleFragment.BubbleCenter.X = 2; originalMessage.SourceBubbleFragment.BubbleCenter.Y = 3; originalMessage.SourceBubbleFragment.BubbleCenter.Z = 4; originalMessage.SourceBubbleFragment.BubbleRange = 5; originalMessage.SourceBubbleFragment.BubblePerceptionRange = 6; originalMessage.SourceBubbleFragment.BubbleRealTime = 7; originalMessage.ProgramName = "TestProgramName"; originalMessage.ProgramMajorVersion = 1; originalMessage.ProgramMinorVersion = 2; originalMessage.ProtocolMajorVersion = 3; originalMessage.ProtocolMinorVersion = 4; originalMessage.ProtocolSourceRevision = 5; SerializeReferenceMessage(originalMessage); } { AttachResponseMessage originalMessage = new AttachResponseMessage(); originalMessage.MessageId = 1; originalMessage.RequestMessageId = 1; originalMessage.FailureCode = 2; originalMessage.TargetBubbleFragment.BubbleId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.TargetBubbleFragment.BubbleName = "TestBubble1"; originalMessage.TargetBubbleFragment.BubbleAssetCacheUrl = "TestCloudUrl"; originalMessage.TargetBubbleFragment.BubbleAddress = "TestBubbleAddress"; originalMessage.TargetBubbleFragment.BubblePort = 1; originalMessage.TargetBubbleFragment.BubbleCenter.X = 2; originalMessage.TargetBubbleFragment.BubbleCenter.Y = 3; originalMessage.TargetBubbleFragment.BubbleCenter.Z = 4; originalMessage.TargetBubbleFragment.BubbleRange = 5; originalMessage.TargetBubbleFragment.BubblePerceptionRange = 6; originalMessage.TargetBubbleFragment.BubbleRealTime = 7; originalMessage.ProgramName = "TestProgramName"; originalMessage.ProgramMajorVersion = 1; originalMessage.ProgramMinorVersion = 2; originalMessage.ProtocolMajorVersion = 3; originalMessage.ProtocolMinorVersion = 4; originalMessage.ProtocolSourceRevision = 5; SerializeReferenceMessage(originalMessage); } { ChallengeRequestMessage originalMessage = new ChallengeRequestMessage(); originalMessage.MessageId = 1; for (int i = 0; i < originalMessage.ChallengeRequestBytes.Length; i++) { originalMessage.ChallengeRequestBytes[i] = (byte)i; } SerializeReferenceMessage(originalMessage); } { ChallengeResponseMessage originalMessage = new ChallengeResponseMessage(); originalMessage.MessageId = 1; for (int i = 0; i < originalMessage.ChallengeResponseBytes.Length; i++) { originalMessage.ChallengeResponseBytes[i] = (byte)i; } SerializeReferenceMessage(originalMessage); } { DetachRequestMessage originalMessage = new DetachRequestMessage(); originalMessage.MessageId = 1; SerializeReferenceMessage(originalMessage); } { DetachResponseMessage originalMessage = new DetachResponseMessage(); originalMessage.MessageId = 1; originalMessage.RequestMessageId = 1; originalMessage.FailureCode = 2; SerializeReferenceMessage(originalMessage); } { JoinRequestMessage originalMessage = new JoinRequestMessage(); originalMessage.MessageId = 1; originalMessage.BubbleId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.BubbleName = "TestBubbleName"; originalMessage.LocationName = "TestLocation"; originalMessage.IdentityProviderUrl = "IdentityProviderUrl"; originalMessage.ParticipantIdentifier = "TestParticipantName"; originalMessage.ParticipantSecret = "TestParticipantPassphrase"; originalMessage.ParticipantRealTime = 10; originalMessage.ProgramName = "TestProgramName"; originalMessage.ProgramMajorVersion = 1; originalMessage.ProgramMinorVersion = 2; originalMessage.ProtocolMajorVersion = 3; originalMessage.ProtocolMinorVersion = 4; originalMessage.ProtocolSourceRevision = 5; SerializeReferenceMessage(originalMessage); } { JoinResponseMessage originalMessage = new JoinResponseMessage(); originalMessage.MessageId = 1; originalMessage.RequestMessageId = 1; originalMessage.FailureCode = 2; originalMessage.BubbleId = Guid.Empty; originalMessage.ParticipantId = Guid.Empty; originalMessage.AvatarId = Guid.Empty; originalMessage.BubbleName = "TestBubbleName"; originalMessage.BubbleAssetCacheUrl = "TestBubbleAssetCacheUrl"; originalMessage.BubbleRange = 3; originalMessage.BubblePerceptionRange = 4; originalMessage.BubbleRealTime = 5; originalMessage.ProgramName = "TestProgramName"; originalMessage.ProgramMajorVersion = 6; originalMessage.ProgramMinorVersion = 7; originalMessage.ProtocolMajorVersion = 8; originalMessage.ProtocolMinorVersion = 9; originalMessage.ProtocolSourceRevision = 10; SerializeReferenceMessage(originalMessage); } { KeepaliveMessage originalMessage = new KeepaliveMessage(); originalMessage.MessageId = 1; SerializeReferenceMessage(originalMessage); } { LeaveRequestMessage originalMessage = new LeaveRequestMessage(); originalMessage.MessageId = 1; SerializeReferenceMessage(originalMessage); } { LeaveResponseMessage originalMessage = new LeaveResponseMessage(); originalMessage.MessageId = 1; originalMessage.RequestMessageId = 1; originalMessage.FailureCode = 2; SerializeReferenceMessage(originalMessage); } { ListBubblesRequest originalMessage = new ListBubblesRequest(); originalMessage.MessageId = 1; originalMessage.ListType = ListBubblesRequest.ListTypeHosted; SerializeReferenceMessage(originalMessage); } { ListBubblesResponse originalMessage = new ListBubblesResponse(); originalMessage.MessageId = 1; { BubbleFragment bubbleEntry = new BubbleFragment(); bubbleEntry.BubbleId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); bubbleEntry.BubbleName = "TestBubble1"; bubbleEntry.BubbleAssetCacheUrl = "TestCloudUrl"; bubbleEntry.BubbleAddress = "TestBubbleAddress"; bubbleEntry.BubblePort = 1; bubbleEntry.BubbleCenter.X = 2; bubbleEntry.BubbleCenter.Y = 3; bubbleEntry.BubbleCenter.Z = 4; bubbleEntry.BubbleRange = 5; bubbleEntry.BubblePerceptionRange = 6; bubbleEntry.BubbleRealTime = 7; originalMessage.AddBubbleFragment(bubbleEntry); } { BubbleFragment bubbleEntry = new BubbleFragment(); bubbleEntry.BubbleId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); bubbleEntry.BubbleName = "TestBubble2"; bubbleEntry.BubbleAssetCacheUrl = "TestCloudUrl"; bubbleEntry.BubbleAddress = "TestBubbleAddress"; bubbleEntry.BubblePort = 1; bubbleEntry.BubbleCenter.X = 2; bubbleEntry.BubbleCenter.Y = 3; bubbleEntry.BubbleCenter.Z = 4; bubbleEntry.BubbleRange = 5; bubbleEntry.BubblePerceptionRange = 6; bubbleEntry.BubbleRealTime = 7; originalMessage.AddBubbleFragment(bubbleEntry); } { BubbleFragment bubbleEntry = new BubbleFragment(); bubbleEntry.BubbleId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); bubbleEntry.BubbleName = "TestBubble3"; bubbleEntry.BubbleAssetCacheUrl = "TestCloudUrl"; bubbleEntry.BubbleAddress = "TestBubbleAddress"; bubbleEntry.BubblePort = 1; bubbleEntry.BubbleCenter.X = 2; bubbleEntry.BubbleCenter.Y = 3; bubbleEntry.BubbleCenter.Z = 4; bubbleEntry.BubbleRange = 5; bubbleEntry.BubblePerceptionRange = 6; bubbleEntry.BubbleRealTime = 7; originalMessage.AddBubbleFragment(bubbleEntry); } { BubbleFragment bubbleEntry = new BubbleFragment(); bubbleEntry.BubbleId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); bubbleEntry.BubbleName = "TestBubble4"; bubbleEntry.BubbleAssetCacheUrl = "TestCloudUrl"; bubbleEntry.BubbleAddress = "TestBubbleAddress"; bubbleEntry.BubblePort = 1; bubbleEntry.BubbleCenter.X = 2; bubbleEntry.BubbleCenter.Y = 3; bubbleEntry.BubbleCenter.Z = 4; bubbleEntry.BubbleRange = 5; bubbleEntry.BubblePerceptionRange = 6; bubbleEntry.BubbleRealTime = 7; originalMessage.AddBubbleFragment(bubbleEntry); } { BubbleFragment bubbleEntry = new BubbleFragment(); bubbleEntry.BubbleId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); bubbleEntry.BubbleName = "TestBubble5"; bubbleEntry.BubbleAssetCacheUrl = "TestCloudUrl"; bubbleEntry.BubbleAddress = "TestBubbleAddress"; bubbleEntry.BubblePort = 1; bubbleEntry.BubbleCenter.X = 2; bubbleEntry.BubbleCenter.Y = 3; bubbleEntry.BubbleCenter.Z = 4; bubbleEntry.BubbleRange = 5; bubbleEntry.BubblePerceptionRange = 6; bubbleEntry.BubbleRealTime = 7; originalMessage.AddBubbleFragment(bubbleEntry); } SerializeReferenceMessage(originalMessage); } { ThrottleMessage originalMessage = new ThrottleMessage(); originalMessage.MessageId = 1; originalMessage.BytesPerSecond = 10000; SerializeReferenceMessage(originalMessage); } // Command messages { EjectRequestMessage originalMessage = new EjectRequestMessage(); originalMessage.MessageId = 1; originalMessage.ObjectId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); SerializeReferenceMessage(originalMessage); } { EjectResponseMessage originalMessage = new EjectResponseMessage(); originalMessage.MessageId = 1; originalMessage.RequestMessageId = 1; originalMessage.FailureCode = 2; SerializeReferenceMessage(originalMessage); } { ExamineRequestMessage originalMessage = new ExamineRequestMessage(); originalMessage.MessageId = 1; originalMessage.ObjectId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectIndex = 1; SerializeReferenceMessage(originalMessage); } { ExamineResponseMessage originalMessage = new ExamineResponseMessage(); originalMessage.MessageId = 1; originalMessage.RequestMessageId = 1; originalMessage.FailureCode = 2; originalMessage.ObjectFragment.ObjectId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.ObjectIndex = 1; originalMessage.ObjectFragment.TypeId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.ObjectName = "TestObjectName"; originalMessage.ObjectFragment.TypeName = "TestTypeName"; originalMessage.ObjectFragment.OwnerId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.Location.X = 1; originalMessage.ObjectFragment.Location.Y = 2; originalMessage.ObjectFragment.Location.Z = 3; originalMessage.ObjectFragment.Velocity.X = 4; originalMessage.ObjectFragment.Velocity.Y = 5; originalMessage.ObjectFragment.Velocity.Z = 6; originalMessage.ObjectFragment.Acceleration.X = 7; originalMessage.ObjectFragment.Acceleration.Y = 8; originalMessage.ObjectFragment.Acceleration.Z = 9; originalMessage.ObjectFragment.Orientation.X = 10; originalMessage.ObjectFragment.Orientation.Y = 11; originalMessage.ObjectFragment.Orientation.Z = 12; originalMessage.ObjectFragment.Orientation.W = 13; originalMessage.ObjectFragment.AngularVelocity.X = 14; originalMessage.ObjectFragment.AngularVelocity.Y = 15; originalMessage.ObjectFragment.AngularVelocity.Z = 16; originalMessage.ObjectFragment.AngularVelocity.W = 17; originalMessage.ObjectFragment.AngularAcceleration.X = 18; originalMessage.ObjectFragment.AngularAcceleration.Y = 19; originalMessage.ObjectFragment.AngularAcceleration.Z = 20; originalMessage.ObjectFragment.AngularAcceleration.W = 21; originalMessage.ObjectFragment.BoundingSphereRadius = 22; originalMessage.ObjectFragment.Mass = 23; originalMessage.ObjectFragment.ExtensionDialect = "TEST"; originalMessage.ObjectFragment.SetExtensionData(UTF8Encoding.UTF8.GetBytes( "1234567890123456789012345678901234567890")); SerializeReferenceMessage(originalMessage); } { HandoverRequestMessage originalMessage = new HandoverRequestMessage(); originalMessage.MessageId = 1; originalMessage.SourceBubbleId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.TargetBubbleId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.ObjectId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.ObjectIndex = 1; originalMessage.ObjectFragment.TypeId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.ObjectName = "TestObjectName"; originalMessage.ObjectFragment.TypeName = "TestTypeName"; originalMessage.ObjectFragment.OwnerId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.Location.X = 1; originalMessage.ObjectFragment.Location.Y = 2; originalMessage.ObjectFragment.Location.Z = 3; originalMessage.ObjectFragment.Velocity.X = 4; originalMessage.ObjectFragment.Velocity.Y = 5; originalMessage.ObjectFragment.Velocity.Z = 6; originalMessage.ObjectFragment.Acceleration.X = 7; originalMessage.ObjectFragment.Acceleration.Y = 8; originalMessage.ObjectFragment.Acceleration.Z = 9; originalMessage.ObjectFragment.Orientation.X = 10; originalMessage.ObjectFragment.Orientation.Y = 11; originalMessage.ObjectFragment.Orientation.Z = 12; originalMessage.ObjectFragment.Orientation.W = 13; originalMessage.ObjectFragment.AngularVelocity.X = 14; originalMessage.ObjectFragment.AngularVelocity.Y = 15; originalMessage.ObjectFragment.AngularVelocity.Z = 16; originalMessage.ObjectFragment.AngularVelocity.W = 17; originalMessage.ObjectFragment.AngularAcceleration.X = 18; originalMessage.ObjectFragment.AngularAcceleration.Y = 19; originalMessage.ObjectFragment.AngularAcceleration.Z = 20; originalMessage.ObjectFragment.AngularAcceleration.W = 21; originalMessage.ObjectFragment.BoundingSphereRadius = 22; originalMessage.ObjectFragment.Mass = 23; originalMessage.ObjectFragment.ExtensionDialect = "TEST"; originalMessage.ObjectFragment.SetExtensionData(UTF8Encoding.UTF8.GetBytes( "1234567890123")); SerializeReferenceMessage(originalMessage); } { HandoverResponseMessage originalMessage = new HandoverResponseMessage(); originalMessage.MessageId = 1; originalMessage.RequestMessageId = 1; originalMessage.FailureCode = 2; SerializeReferenceMessage(originalMessage); } { InjectRequestMessage originalMessage = new InjectRequestMessage(); originalMessage.MessageId = 1; originalMessage.ObjectFragment.ObjectId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.ObjectIndex = 1; originalMessage.ObjectFragment.TypeId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.ObjectName = "TestObjectName"; originalMessage.ObjectFragment.TypeName = "TestTypeName"; originalMessage.ObjectFragment.OwnerId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.Location.X = 1; originalMessage.ObjectFragment.Location.Y = 2; originalMessage.ObjectFragment.Location.Z = 3; originalMessage.ObjectFragment.Velocity.X = 4; originalMessage.ObjectFragment.Velocity.Y = 5; originalMessage.ObjectFragment.Velocity.Z = 6; originalMessage.ObjectFragment.Acceleration.X = 7; originalMessage.ObjectFragment.Acceleration.Y = 8; originalMessage.ObjectFragment.Acceleration.Z = 9; originalMessage.ObjectFragment.Orientation.X = 10; originalMessage.ObjectFragment.Orientation.Y = 11; originalMessage.ObjectFragment.Orientation.Z = 12; originalMessage.ObjectFragment.Orientation.W = 13; originalMessage.ObjectFragment.AngularVelocity.X = 14; originalMessage.ObjectFragment.AngularVelocity.Y = 15; originalMessage.ObjectFragment.AngularVelocity.Z = 16; originalMessage.ObjectFragment.AngularVelocity.W = 17; originalMessage.ObjectFragment.AngularAcceleration.X = 18; originalMessage.ObjectFragment.AngularAcceleration.Y = 19; originalMessage.ObjectFragment.AngularAcceleration.Z = 20; originalMessage.ObjectFragment.AngularAcceleration.W = 21; originalMessage.ObjectFragment.BoundingSphereRadius = 22; originalMessage.ObjectFragment.Mass = 23; originalMessage.ObjectFragment.ExtensionDialect = "TEST"; originalMessage.ObjectFragment.ExtensionDialectMajorVersion = 24; originalMessage.ObjectFragment.ExtensionDialectMinorVersion = 25; originalMessage.ObjectFragment.SetExtensionData(UTF8Encoding.UTF8.GetBytes( "123456789012345678901234567890123456789012345")); SerializeReferenceMessage(originalMessage); } { InjectResponseMessage originalMessage = new InjectResponseMessage(); originalMessage.MessageId = 1; originalMessage.RequestMessageId = 1; originalMessage.FailureCode = 2; SerializeReferenceMessage(originalMessage); } { InteractRequestMessage originalMessage = new InteractRequestMessage(); originalMessage.MessageId = 1; originalMessage.InteractionFragment.InteractionName = "TestInteractionName"; originalMessage.InteractionFragment.SourceParticipantId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.InteractionFragment.SourceObjectId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.InteractionFragment.TargetParticipantId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.InteractionFragment.TargetObjectId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.InteractionFragment.ExtensionDialect = "TEST"; originalMessage.SetInteractionPayloadData(UTF8Encoding.UTF8.GetBytes( "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901")); SerializeReferenceMessage(originalMessage); } { InteractResponseMessage originalMessage = new InteractResponseMessage(); originalMessage.MessageId = 1; originalMessage.RequestMessageId = 1; originalMessage.FailureCode = 2; originalMessage.InteractionFragment.InteractionName = "TestInteractionName"; originalMessage.InteractionFragment.SourceParticipantId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.InteractionFragment.SourceObjectId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.InteractionFragment.TargetParticipantId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.InteractionFragment.TargetObjectId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.InteractionFragment.ExtensionDialect = "TEST"; originalMessage.SetInteractionPayloadData(UTF8Encoding.UTF8.GetBytes( "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + "12345678901234567890123456789012345678901234567890123456")); SerializeReferenceMessage(originalMessage); } { ModifyRequestMessage originalMessage = new ModifyRequestMessage(); originalMessage.MessageId = 1; originalMessage.ObjectFragment.ObjectId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.ObjectIndex = 1; originalMessage.ObjectFragment.TypeId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.ObjectName = "TestObjectName"; originalMessage.ObjectFragment.TypeName = "TestTypeName"; originalMessage.ObjectFragment.OwnerId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.Location.X = 1; originalMessage.ObjectFragment.Location.Y = 2; originalMessage.ObjectFragment.Location.Z = 3; originalMessage.ObjectFragment.Velocity.X = 4; originalMessage.ObjectFragment.Velocity.Y = 5; originalMessage.ObjectFragment.Velocity.Z = 6; originalMessage.ObjectFragment.Acceleration.X = 7; originalMessage.ObjectFragment.Acceleration.Y = 8; originalMessage.ObjectFragment.Acceleration.Z = 9; originalMessage.ObjectFragment.Orientation.X = 10; originalMessage.ObjectFragment.Orientation.Y = 11; originalMessage.ObjectFragment.Orientation.Z = 12; originalMessage.ObjectFragment.Orientation.W = 13; originalMessage.ObjectFragment.AngularVelocity.X = 14; originalMessage.ObjectFragment.AngularVelocity.Y = 15; originalMessage.ObjectFragment.AngularVelocity.Z = 16; originalMessage.ObjectFragment.AngularVelocity.W = 17; originalMessage.ObjectFragment.AngularAcceleration.X = 18; originalMessage.ObjectFragment.AngularAcceleration.Y = 19; originalMessage.ObjectFragment.AngularAcceleration.Z = 20; originalMessage.ObjectFragment.AngularAcceleration.W = 21; originalMessage.ObjectFragment.BoundingSphereRadius = 22; originalMessage.ObjectFragment.Mass = 23; originalMessage.ObjectFragment.ExtensionDialect = "TEST"; originalMessage.ObjectFragment.SetExtensionData(UTF8Encoding.UTF8.GetBytes( "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678")); SerializeReferenceMessage(originalMessage); } { ModifyResponseMessage originalMessage = new ModifyResponseMessage(); originalMessage.MessageId = 1; originalMessage.RequestMessageId = 1; originalMessage.FailureCode = 2; SerializeReferenceMessage(originalMessage); } // Event messages { ActionEventMessage originalMessage = new ActionEventMessage(); originalMessage.MessageId = 1; originalMessage.ActionFragment.ActionName = "TestInteractionName"; originalMessage.ActionFragment.SourceObjectId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ActionFragment.ObservationRadius = 100; originalMessage.ActionFragment.ExtensionDialect = "TEST"; originalMessage.ActionFragment.ExtensionDialectMajorVersion = 1; originalMessage.ActionFragment.ExtensionDialectMinorVersion = 2; originalMessage.SetPayloadData(UTF8Encoding.UTF8.GetBytes( "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + "12345")); SerializeReferenceMessage(originalMessage); } { DisappearanceEventMessage originalMessage = new DisappearanceEventMessage(); originalMessage.MessageId = 1; originalMessage.ObjectIndex = 1; SerializeReferenceMessage(originalMessage); } { HandoverEventMessage originalMessage = new HandoverEventMessage(); originalMessage.MessageId = 1; originalMessage.SourceBubbleId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.TargetBubbleId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.ObjectId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.ObjectIndex = 1; originalMessage.ObjectFragment.TypeId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.ObjectName = "TestObjectName"; originalMessage.ObjectFragment.TypeName = "TestTypeName"; originalMessage.ObjectFragment.OwnerId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.Location.X = 1; originalMessage.ObjectFragment.Location.Y = 2; originalMessage.ObjectFragment.Location.Z = 3; originalMessage.ObjectFragment.Velocity.X = 4; originalMessage.ObjectFragment.Velocity.Y = 5; originalMessage.ObjectFragment.Velocity.Z = 6; originalMessage.ObjectFragment.Acceleration.X = 7; originalMessage.ObjectFragment.Acceleration.Y = 8; originalMessage.ObjectFragment.Acceleration.Z = 9; originalMessage.ObjectFragment.Orientation.X = 10; originalMessage.ObjectFragment.Orientation.Y = 11; originalMessage.ObjectFragment.Orientation.Z = 12; originalMessage.ObjectFragment.Orientation.W = 13; originalMessage.ObjectFragment.AngularVelocity.X = 14; originalMessage.ObjectFragment.AngularVelocity.Y = 15; originalMessage.ObjectFragment.AngularVelocity.Z = 16; originalMessage.ObjectFragment.AngularVelocity.W = 17; originalMessage.ObjectFragment.AngularAcceleration.X = 18; originalMessage.ObjectFragment.AngularAcceleration.Y = 19; originalMessage.ObjectFragment.AngularAcceleration.Z = 20; originalMessage.ObjectFragment.AngularAcceleration.W = 21; originalMessage.ObjectFragment.BoundingSphereRadius = 22; originalMessage.ObjectFragment.Mass = 23; originalMessage.ObjectFragment.ExtensionDialect = "TEST"; originalMessage.ObjectFragment.SetExtensionData(UTF8Encoding.UTF8.GetBytes( "1234567890123")); SerializeReferenceMessage(originalMessage); } { MovementEventMessage originalMessage = new MovementEventMessage(); originalMessage.MessageId = 1; originalMessage.ObjectIndex = 1; originalMessage.Location.X = 1; originalMessage.Location.Y = 2; originalMessage.Location.Z = 3; originalMessage.Orientation.X = 10; originalMessage.Orientation.Y = 11; originalMessage.Orientation.Z = 12; originalMessage.Orientation.W = 13; SerializeReferenceMessage(originalMessage); } { PerceptionEventMessage originalMessage = new PerceptionEventMessage(); originalMessage.MessageId = 1; originalMessage.ObjectFragment.ObjectId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.ObjectIndex = 1; originalMessage.ObjectFragment.TypeId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.ObjectName = "TestObjectName"; originalMessage.ObjectFragment.TypeName = "TestTypeName"; originalMessage.ObjectFragment.OwnerId = new Guid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); originalMessage.ObjectFragment.Location.X = 1; originalMessage.ObjectFragment.Location.Y = 2; originalMessage.ObjectFragment.Location.Z = 3; originalMessage.ObjectFragment.Velocity.X = 4; originalMessage.ObjectFragment.Velocity.Y = 5; originalMessage.ObjectFragment.Velocity.Z = 6; originalMessage.ObjectFragment.Acceleration.X = 7; originalMessage.ObjectFragment.Acceleration.Y = 8; originalMessage.ObjectFragment.Acceleration.Z = 9; originalMessage.ObjectFragment.Orientation.X = 10; originalMessage.ObjectFragment.Orientation.Y = 11; originalMessage.ObjectFragment.Orientation.Z = 12; originalMessage.ObjectFragment.Orientation.W = 13; originalMessage.ObjectFragment.AngularVelocity.X = 14; originalMessage.ObjectFragment.AngularVelocity.Y = 15; originalMessage.ObjectFragment.AngularVelocity.Z = 16; originalMessage.ObjectFragment.AngularVelocity.W = 17; originalMessage.ObjectFragment.AngularAcceleration.X = 18; originalMessage.ObjectFragment.AngularAcceleration.Y = 19; originalMessage.ObjectFragment.AngularAcceleration.Z = 20; originalMessage.ObjectFragment.AngularAcceleration.W = 21; originalMessage.ObjectFragment.BoundingSphereRadius = 22; originalMessage.ObjectFragment.Mass = 23; originalMessage.ObjectFragment.ExtensionDialect = "TEST"; originalMessage.ObjectFragment.SetExtensionData(UTF8Encoding.UTF8.GetBytes( "123456789012345678901234567890123456789012345")); SerializeReferenceMessage(originalMessage); } { SynchronizationBeginEventMessage originalMessage = new SynchronizationBeginEventMessage(); originalMessage.MessageId = 1; originalMessage.ObjectCount = 1; SerializeReferenceMessage(originalMessage); } { SynchronizationEndEventMessage originalMessage = new SynchronizationEndEventMessage(); originalMessage.MessageId = 1; SerializeReferenceMessage(originalMessage); } udpClient.Close(); udpClient = null; }
public void OnInteractRequest(InteractRequestMessage interactRequest) { if (interactRequest.InteractionFragment.InteractionName == "TypeList") { InteractResponseMessage interactionResponse = (InteractResponseMessage)MessageFactory.Current.ReserveMessage(typeof(InteractResponseMessage)); interactionResponse.RequestMessageId = interactRequest.MessageId; interactionResponse.FailureCode = MxpResponseCodes.SUCCESS; interactionResponse.InteractionFragment.InteractionName = "TypeList"; interactionResponse.InteractionFragment.TargetParticipantId = interactRequest.InteractionFragment.SourceParticipantId; interactionResponse.InteractionFragment.SourceParticipantId = interactRequest.InteractionFragment.TargetParticipantId; OmTypeListResponseExt responseExt = new OmTypeListResponseExt(); List <DaemonLogic.ObjectType> objectTypes = (from t in entityContext.ObjectType orderby t.Name select t).ToList <DaemonLogic.ObjectType>(); foreach (DaemonLogic.ObjectType objectType in objectTypes) { OmObjectType omObjectType = new OmObjectType(); omObjectType.TypeId = objectType.ObjectTypeId.ToString(); omObjectType.TypeName = objectType.Name; responseExt.ObjectType.Add(omObjectType); } interactionResponse.SetExtension <OmTypeListResponseExt>(responseExt); client.SendInteractResponse(interactionResponse); } if (interactRequest.InteractionFragment.InteractionName == "ObjectInsert") { OmInsertRequestExt requestExt = interactRequest.GetExtension <OmInsertRequestExt>(); Guid typeId = new Guid(requestExt.TypeId); ObjectType objectType = QueryUtil.First <DaemonLogic.ObjectType>(from t in entityContext.ObjectType where t.ObjectTypeId == typeId select t); entityContext.Refresh(System.Data.Objects.RefreshMode.StoreWins, objectType); Participant participant = QueryUtil.First <DaemonLogic.Participant>(from p in entityContext.Participant where p.ParticipantId == interactRequest.InteractionFragment.SourceParticipantId select p); DaemonLogic.CloudObject cloudObject = new DaemonLogic.CloudObject { CloudObjectId = Guid.NewGuid(), Participant = participant, ObjectType = objectType, Bubble = bubble, Name = "New " + objectType.Name, Radius = objectType.Radius, Mass = objectType.Mass, ModelUrl = objectType.ModelUrl, ModelScale = objectType.ModelScale, X = requestExt.Location.X, Y = requestExt.Location.Y, Z = requestExt.Location.Z, OX = requestExt.Orientation.X, OY = requestExt.Orientation.Y, OZ = requestExt.Orientation.Z, OW = requestExt.Orientation.W, Created = DateTime.Now, Modified = DateTime.Now, Enabled = true }; entityContext.AddToCloudObject(cloudObject); entityContext.SaveChanges(); InjectOrUpdateObject(cloudObject); InteractResponseMessage interactionResponse = (InteractResponseMessage)MessageFactory.Current.ReserveMessage(typeof(InteractResponseMessage)); interactionResponse.RequestMessageId = interactRequest.MessageId; interactionResponse.FailureCode = MxpResponseCodes.SUCCESS; interactionResponse.InteractionFragment.InteractionName = "ObjectInsert"; interactionResponse.InteractionFragment.TargetParticipantId = interactRequest.InteractionFragment.SourceParticipantId; interactionResponse.InteractionFragment.SourceParticipantId = interactRequest.InteractionFragment.TargetParticipantId; OmInsertResponseExt responseExt = new OmInsertResponseExt(); responseExt.ObjectId = cloudObject.CloudObjectId.ToString(); interactionResponse.SetExtension <OmInsertResponseExt>(responseExt); client.SendInteractResponse(interactionResponse); } if (interactRequest.InteractionFragment.InteractionName == "ObjectUpdate") { OmUpdateRequestExt requestExt = interactRequest.GetExtension <OmUpdateRequestExt>(); Guid objectId = new Guid(requestExt.ObjectId); byte failureCode = MxpResponseCodes.SUCCESS; if (IdObjectDictionary.ContainsKey(objectId)) { DaemonLogic.CloudObject cloudObject = IdObjectDictionary[objectId]; if (cloudObject.Participant.ParticipantId != interactRequest.InteractionFragment.SourceParticipantId && bubble.Participant.ParticipantId != interactRequest.InteractionFragment.SourceParticipantId) { failureCode = MxpResponseCodes.UNAUTHORIZED_OPERATION; } else { cloudObject.Name = requestExt.Name; cloudObject.Radius = requestExt.Scale; cloudObject.X = requestExt.Location.X; cloudObject.Y = requestExt.Location.Y; cloudObject.Z = requestExt.Location.Z; cloudObject.OX = requestExt.Orientation.X; cloudObject.OY = requestExt.Orientation.Y; cloudObject.OZ = requestExt.Orientation.Z; cloudObject.OW = requestExt.Orientation.W; cloudObject.Modified = DateTime.Now; entityContext.SaveChanges(); InjectOrUpdateObject(cloudObject); } } else { failureCode = MxpResponseCodes.UNKNOWN_ID; } InteractResponseMessage interactionResponse = (InteractResponseMessage)MessageFactory.Current.ReserveMessage(typeof(InteractResponseMessage)); interactionResponse.RequestMessageId = interactRequest.MessageId; interactionResponse.FailureCode = failureCode; interactionResponse.InteractionFragment.InteractionName = "ObjectUpdate"; interactionResponse.InteractionFragment.TargetParticipantId = interactRequest.InteractionFragment.SourceParticipantId; interactionResponse.InteractionFragment.SourceParticipantId = interactRequest.InteractionFragment.TargetParticipantId; client.SendInteractResponse(interactionResponse); } if (interactRequest.InteractionFragment.InteractionName == "ObjectDelete") { OmDeleteRequestExt requestExt = interactRequest.GetExtension <OmDeleteRequestExt>(); Guid objectId = new Guid(requestExt.ObjectId); byte failureCode = MxpResponseCodes.SUCCESS; if (this.IdObjectDictionary.ContainsKey(objectId)) { DaemonLogic.CloudObject cloudObject = IdObjectDictionary[objectId]; if (cloudObject.Participant.ParticipantId != interactRequest.InteractionFragment.SourceParticipantId && bubble.Participant.ParticipantId != interactRequest.InteractionFragment.SourceParticipantId) { failureCode = MxpResponseCodes.UNAUTHORIZED_OPERATION; } else { entityContext.DeleteObject(cloudObject); entityContext.SaveChanges(); EjectObject(cloudObject); } } else { failureCode = MxpResponseCodes.UNKNOWN_ID; } InteractResponseMessage interactionResponse = (InteractResponseMessage)MessageFactory.Current.ReserveMessage(typeof(InteractResponseMessage)); interactionResponse.RequestMessageId = interactRequest.MessageId; interactionResponse.FailureCode = failureCode; interactionResponse.InteractionFragment.InteractionName = "ObjectDelete"; interactionResponse.InteractionFragment.TargetParticipantId = interactRequest.InteractionFragment.SourceParticipantId; interactionResponse.InteractionFragment.SourceParticipantId = interactRequest.InteractionFragment.TargetParticipantId; client.SendInteractResponse(interactionResponse); } }