public void TestPadding() { OSCString str = new OSCString("test"); Assert.Equal(8, str.Bytes.Length); str = new OSCString("#bundle"); Assert.Equal(8, str.Bytes.Length); str = new OSCString(""); Assert.Equal(4, str.Bytes.Length); }
private byte[] GetBytes() { byte[] bytes = new byte[GetByteLength()]; MemoryStream stream = new MemoryStream(bytes); stream.Write(Address.Bytes, 0, Address.Bytes.Length); OSCString typeTag = GetTypeTagString(); stream.Write(typeTag.Bytes, 0, typeTag.Bytes.Length); foreach (IOSCValue value in Arguments) { stream.Write(value.Bytes, 0, value.Bytes.Length); } return(bytes); }
public static new OSCBundle Parse(BinaryReader reader) { OSCString bundleString = OSCString.Parse(reader); OSCTimeTag timeTag = OSCTimeTag.Parse(reader); List <OSCPacket> contents = new List <OSCPacket>(); while (reader.BaseStream.Position < reader.BaseStream.Length) { OSCInt size = OSCInt.Parse(reader); OSCPacket packet = OSCPacket.Parse(reader); contents.Add(packet); } return(new OSCBundle(timeTag.Contents, contents)); }
public static new OSCMessage Parse(BinaryReader reader) { OSCString address = OSCString.Parse(reader); OSCString typeTags = OSCString.Parse(reader); int valueCount = typeTags.Contents.Length - 1; List <IOSCValue> values = new List <IOSCValue>(); foreach (char current in typeTags.Contents.Substring(1)) { IOSCValue value = OSCValue.Parse(current, reader); values.Add(value); } return(new OSCMessage(address.Contents, values)); }
public OSCMessage(string address, params object[] values) { Address = new OSCString(address); Arguments = new List <IOSCValue>(); foreach (object obj in values) { if (obj is IOSCValue) { Arguments.Add(obj as IOSCValue); } else { Arguments.Add(OSCValue.Wrap(obj)); } } Bytes = GetBytes(); }
public OSCBundle(DateTime time, IEnumerable <OSCPacket> contents) { Contents = new List <OSCPacket>(contents); Bytes = new byte[GetByteLength()]; MemoryStream stream = new MemoryStream(Bytes); OSCString bundleString = new OSCString("#bundle"); stream.Write(bundleString.Bytes, 0, bundleString.Bytes.Length); TimeTag = new OSCTimeTag(time); stream.Write(TimeTag.Bytes, 0, TimeTag.Bytes.Length); foreach (OSCPacket message in contents) { stream.Write(OSCInt.GetBigEndianIntBytes(message.Bytes.Length), 0, sizeof(int)); stream.Write(message.Bytes, 0, message.Bytes.Length); } }
private int GetTypeTagLength() { return(OSCString.GetPaddedLength(Arguments.Count + 2)); }
public OSCMessage(string address, IEnumerable <IOSCValue> values) { Address = new OSCString(address); Arguments = new List <IOSCValue>(values); Bytes = GetBytes(); }
public void TestParsing(string value) { Assert.Equal(value, OSCValueTester.TestOSCValueParser(value, (reader) => OSCString.Parse(reader))); }