// PACK METHODS private static byte[] PackInternal(IOSCPacket packet, ref int index) { if (_bufferIndex >= _buffers.Count) { _bufferIndex = 0; throw new Exception($"[OSCConverter.PackInternal] You have reached the nesting package depth limit. Maximum depth of nested packages: {_buffers.Count}\nTo change the depth use: OSCConverter.SetBuffersDepth() method."); } var buffer = _buffers[_bufferIndex]; _bufferIndex++; if (packet.IsBundle()) { PackBundle((OSCBundle)packet, buffer, ref index); } else { PackMessage((OSCMessage)packet, buffer, ref index); } _bufferIndex--; return(buffer); }
public static void SavePacket(string filePath, IOSCPacket packet) { using (var fileWriter = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite)) { var length = OSCConverter.Pack(packet, out var buffer); fileWriter.Write(buffer, 0, length); } }
public void AddPacket(IOSCPacket packet) { if (packet == null) { throw new NullReferenceException(nameof(packet)); } Packets.Add(packet); }
/// <summary> /// Serializes a IOSCPacket and writes it to a buffer, returning the size of the packet. /// </summary> /// <param name="packet">packet</param> /// <param name="size">Serialized packet size</param> /// <returns>Buffer with a fixed value.</returns> public static int Pack(IOSCPacket packet, out byte[] buffer) { lock (_lock) { var size = 0; buffer = PackInternal(packet, ref size); return(size); } }
public static void Transmitted(OSCEditorTransmitter transmitter, IOSCPacket packet) { var message = new OSCConsolePacket(); message.Info = $"<color=green>Editor Transmitter</color>: {transmitter.RemoteHost}:{transmitter.RemotePort}"; message.PacketType = OSCConsolePacketType.Transmitted; message.Packet = packet; Log(message); }
public static void Received(OSCEditorReceiver receiver, IOSCPacket packet) { var message = new OSCConsolePacket(); message.Info = $"<color=green>Editor Receiver</color>: {receiver.LocalPort}. From: {(packet.Ip != null ? packet.Ip.ToString() : "Debug")}"; message.PacketType = OSCConsolePacketType.Received; message.Packet = packet; Log(message); }
private void OpenPacket() { var file = EditorUtility.OpenFilePanel("Open Packet", OSCEditorUtils.DebugFolder, "eod"); if (!string.IsNullOrEmpty(file)) { FilePath = file; CurrentPacket = OSCEditorUtils.LoadPacket(file); } }
public static void Transmitted(OSCTransmitter transmitter, IOSCPacket packet) { var consolePacket = new OSCConsolePacket(); consolePacket.Info = $"Transmitter: {transmitter.RemoteHost}:{transmitter.RemotePort}"; consolePacket.PacketType = OSCConsolePacketType.Transmitted; consolePacket.Packet = packet; Log(consolePacket); }
public static void Transmitted(OSCTransmitter transmitter, IOSCPacket packet) { var consolePacket = new OSCConsolePacket(); consolePacket.Info = $"Transmitter: {transmitter.RemoteHost}:{transmitter.RemotePort}"; consolePacket.TimeStamp = DateTime.Now.ToString("[HH:mm:ss]"); consolePacket.PacketType = OSCConsolePacketType.Transmitted; consolePacket.Packet = packet; Log(consolePacket); }
public void DrawLayout(IOSCPacket packet) { if (packet.IsBundle()) { DrawBundle((OSCBundle)packet); } else { DrawMessage((OSCMessage)packet); } }
public IOSCPacket Copy() { var packetsCount = Packets.Count; var packets = new IOSCPacket[packetsCount]; for (var i = 0; i < packetsCount; ++i) { packets[i] = Packets[i].Copy(); } return(new OSCBundle(packets)); }
public static void Received(OSCReceiver receiver, IOSCPacket packet) { var ip = packet.Ip != null ? $"{packet.Ip}:{packet.Port}" : "Debug"; var consolePacket = new OSCConsolePacket(); consolePacket.Info = $"Receiver: {receiver.LocalPort}. From: {ip}"; consolePacket.PacketType = OSCConsolePacketType.Received; consolePacket.Packet = packet; Log(consolePacket); }
private void CreatePacket(object userData, string[] options, int selected) { if (selected == 0) { CurrentPacket = new OSCMessage("/address"); } else { CurrentPacket = new OSCBundle(); } FilePath = string.Empty; }
public static void Received(OSCReceiver receiver, IOSCPacket packet) { var ip = packet.Ip != null ? $"{packet.Ip}:{packet.Port}" : "Debug"; var consolePacket = new OSCConsolePacket(); consolePacket.Info = $"Receiver: {receiver.LocalPort}. From: {ip}"; consolePacket.TimeStamp = DateTime.Now.ToString("[HH:mm:ss]"); consolePacket.PacketType = OSCConsolePacketType.Received; consolePacket.Packet = packet; Log(consolePacket); }
public static string GeneratePacket(IOSCPacket packet) { if (packet is OSCBundle bundle) { return(GenerateBundle(bundle)); } if (packet is OSCMessage message) { return(GenerateMessage(message)); } return(string.Empty); }
/// <summary> /// Serializes a packet and returns the packet data in byte array. /// </summary> /// <param name="packet">packet</param> /// <returns>packet data</returns> public static byte[] Pack(IOSCPacket packet) { lock (_lock) { var size = 0; var buffer = PackInternal(packet, ref size); var bytes = new byte[size]; Buffer.BlockCopy(buffer, 0, bytes, 0, size); return(bytes); } }
private void CreatePacket(object userData, string[] options, int selected) { CurrentPacket = selected == 0 ? (IOSCPacket) new OSCMessage("/address") : new OSCBundle(); FilePath = string.Empty; }
public static void OpenPacket(IOSCPacket packet) { Open(); Instance._packetEditorPanel.CurrentPacket = packet.Copy(); }
public static string GeneratePacket(IOSCPacket packet) { return(packet.IsBundle() ? GenerateBundle(packet as OSCBundle) : GenerateMessage(packet as OSCMessage)); }
public static string ToBase64String(IOSCPacket packet) { var length = OSCConverter.Pack(packet, out var buffer); return(Convert.ToBase64String(buffer, 0, length)); }