internal static void AreEqual(OscBundle expected, OscBundle actual) { Assert.AreEqual(expected.Error, actual.Error, "Error states do not match"); Assert.AreEqual(expected.ErrorMessage, actual.ErrorMessage, "Error messages do not match"); Assert.AreEqual(expected.Timestamp, actual.Timestamp, "Message timestamps do not match"); AreEqual(expected.ToArray(), actual.ToArray()); }
public void OscBundleConstructorTest() { OscTimeTag timestamp = new OscTimeTag(14236589681638796952); OscMessage[] messages = new OscMessage[] { UnitTestHelper.Message_Array_Ints(), UnitTestHelper.Message_Array_Ints() }; OscBundle target = new OscBundle(timestamp, messages); Assert.AreEqual(timestamp, target.Timestamp); UnitTestHelper.AreEqual(messages, target.ToArray()); }
internal static void AreEqual(OscBundle expected, OscBundle actual) { Assert.Equal(expected.Timestamp, actual.Timestamp); // , "Message timestamps do not match"); AreEqual(expected.ToArray(), actual.ToArray()); }
// Loop for listening and updating dashboard data. static void ListenLoop() { try { while (Receiver.State != OscSocketState.Closed) { if (Receiver.State == OscSocketState.Connected) { // Get the next message, this will block until one arrives or the socket is closed. OscPacket Packet = Receiver.Receive(); // Slap the packet in the most recent message variable. App.Current.Dispatcher.InvokeAsync(() => { // Parses the packet into a message array. OscBundle MessageBundle = OscBundle.Parse(Packet.ToString()); foreach (OscPacket MessagePacket in MessageBundle.ToArray()) { // Get the latest message. OscMessage LatestMessage = OscMessage.Parse(MessagePacket.ToString()); // Determine if the message should be overwritten. bool OverwriteMessage = false; int OverwriteMessageIndex = 0; foreach (OscData Message in ReceivedOscData) { if (Message.Path == LatestMessage.Address) { OverwriteMessageIndex = ReceivedOscData.IndexOf(Message); OverwriteMessage = true; } } // Cut the address out of the data string. string DataString = ""; string[] DataArray = LatestMessage.ToString().Split(','); for (int i = 1; i < DataArray.Length; i++) { DataString += DataArray[i]; } // Add the message to the data grid, or overwrite its data. if (OverwriteMessage) { ReceivedOscData.RemoveAt(OverwriteMessageIndex); ReceivedOscData.Insert(OverwriteMessageIndex, new OscData() { Path = LatestMessage.Address, Data = DataString }); } else { ReceivedOscData.Add(new OscData() { Path = LatestMessage.Address, Data = DataString }); } } }); } } } catch (Exception Ex) { // Display the exeception if it occurred, while receiving. if (Receiver.State == OscSocketState.Connected) { MessageBox.Show(Ex.Message, "Exception Occurred", MessageBoxButton.OK, MessageBoxImage.Warning); } } }