public static new OSCBundle Unpack(byte[] bytes, ref int start, int end) { OSCBundle bundle = new OSCBundle(); string address = unpackString(bytes, ref start); if (!address.Equals(BUNDLE)) { return(null); // TODO } long time = unpackLong(bytes, ref start); while (start < end) { int subEnd = unpackInt(bytes, ref start); bundle.Append(OSCPacket.Unpack(bytes, ref start, subEnd)); } return(bundle); }
public static new OSCBundle Unpack(byte[] bytes, ref int start, int end) { string address = unpackString(bytes, ref start); //Console.WriteLine("bundle: " + address); if (!address.Equals(BUNDLE)) { return(null); // TODO } long timestamp = unpackLong(bytes, ref start); OSCBundle bundle = new OSCBundle(timestamp); while (start < end) { int length = unpackInt(bytes, ref start); int sub_end = start + length; //Console.WriteLine(bytes.Length +" "+ start+" "+length+" "+sub_end); bundle.Append(OSCPacket.Unpack(bytes, ref start, sub_end)); } return(bundle); }
/// <summary> /// EndReceive paired call. /// </summary> /// <param name="asyncResult">Paired result object from the BeginReceive call.</param> private void EndReceive(IAsyncResult asyncResult) { try { UdpState udpState = (UdpState)asyncResult.AsyncState; UdpClient udpClient = udpState.Client; IPEndPoint ipEndPoint = udpState.IPEndPoint; byte[] data = udpClient.EndReceive(asyncResult, ref ipEndPoint); if (data != null && data.Length > 0) { if (cb != null) { cb(OSCPacket.Unpack(data)); } } udpClient.BeginReceive(mAsyncCallback, udpState); } catch (ObjectDisposedException) { // Suppress error } }