public void OnObjectAction(ActionEventMessage actionEvent) { if ("Chat".Equals(actionEvent.ActionFragment.ActionName)) { OmChatExt omChatExt = actionEvent.GetExtension <OmChatExt>(); DeckProgram.DeckScene.AddChatMessage(actionEvent.ActionFragment.SourceObjectId, omChatExt.Message); } }
public void ActionMessageEncoding() { ActionEventMessage originalMessage = new ActionEventMessage(); originalMessage.ActionFragment.ActionName = "TestInteractionName"; originalMessage.ActionFragment.SourceObjectId = Guid.NewGuid(); originalMessage.ActionFragment.ObservationRadius = 100; OmChatExt originalChatFragment = new OmChatExt(); originalChatFragment.Message = "TestChatMessage"; originalMessage.SetExtension <OmChatExt>(originalChatFragment); byte[] encodedBytes = new byte[MxpConstants.MaxPacketSize]; Assert.AreEqual(originalMessage.FrameCount, 1); Assert.AreEqual(originalMessage.FrameDataSize(0), 67); int currentIndex = originalMessage.EncodeFrameData(0, encodedBytes, 0); ActionEventMessage decodedMessage = new ActionEventMessage(); decodedMessage.MessageId = originalMessage.MessageId; int currentDecodeIndex = decodedMessage.DecodeFrameData(0, encodedBytes, 0, originalMessage.FrameDataSize(0)); OmChatExt decodedChatFragment = decodedMessage.GetExtension <OmChatExt>(); String originalMessageString = originalMessage.ToString(); String decodedMessageString = decodedMessage.ToString(); Assert.AreEqual(originalMessageString, decodedMessageString); Assert.AreEqual(originalChatFragment.Message, decodedChatFragment.Message); }