private async void onUpdate(object caller, EventArgs args) { if (tabStrip.SelectedItem == tabStatus && udpClient != null) { bool joystickPressed = false; if (joystick != null) { joystickPressed = joystick.GetCurrentState().Buttons.Any(x => x); } bool isSafe = joystickPressed || System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.Space); safetyStatus.Status = isSafe; string oscAddress = "/group/" + Properties.Settings.Default.Group + "/FireSafety"; OscMessage message = new OscMessage(null, oscAddress, safetyStatus.StatusFloat); var bytes = message.ToByteArray(); try { IPAddress[] addresses = await Dns.GetHostAddressesAsync(Properties.Settings.Default.Hostname); foreach (var address in addresses.Where(x => x.AddressFamily == AddressFamily.InterNetwork)) { IPEndPoint endPoint = new IPEndPoint(address, Properties.Settings.Default.Port); await udpClient.SendAsync(bytes, bytes.Length, endPoint); } } catch (Exception e) { safetyStatus.Error = e; } } }
public void TestArraySerialisation() { var data = new object[] { 1, 2f, "foo" }; var msg = new OscMessage("/test", data); var expected = CreateExpectedDataArray(); msg.TypeTag.Should().Be(",[ifs]"); OscValidation.AssertSamePacket(expected, msg.ToByteArray()); }
public void TestArraySerialisation3() { var msg = new OscMessage("/test", new object[] { 1, 2f, "foo" }); msg.Append(1); // the last argument is an integer. var expected = CreateExpectedDataArray3(); msg.TypeTag.Should().Be(",[ifs]i"); OscValidation.AssertSamePacket(expected, msg.ToByteArray()); }
public void TestArraySerialisation4() { var msg = new OscMessage("/test", new object[] { 1, 2f, "foo" }); var blob = CreateTestBlob(); msg.Append(blob); // the last argument is a blob. var expected = CreateExpectedDataArray4(); msg.TypeTag.Should().Be(",[ifs]b"); OscValidation.AssertSamePacket(expected, msg.ToByteArray()); }