예제 #1
0
        //  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);
        }
예제 #2
0
 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);
     }
 }
예제 #3
0
파일: OSCBundle.cs 프로젝트: Iam1337/extOSC
        public void AddPacket(IOSCPacket packet)
        {
            if (packet == null)
            {
                throw new NullReferenceException(nameof(packet));
            }

            Packets.Add(packet);
        }
예제 #4
0
 /// <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);
     }
 }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        private void OpenPacket()
        {
            var file = EditorUtility.OpenFilePanel("Open Packet", OSCEditorUtils.DebugFolder, "eod");

            if (!string.IsNullOrEmpty(file))
            {
                FilePath      = file;
                CurrentPacket = OSCEditorUtils.LoadPacket(file);
            }
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
 public void DrawLayout(IOSCPacket packet)
 {
     if (packet.IsBundle())
     {
         DrawBundle((OSCBundle)packet);
     }
     else
     {
         DrawMessage((OSCMessage)packet);
     }
 }
예제 #11
0
파일: OSCBundle.cs 프로젝트: Iam1337/extOSC
        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));
        }
예제 #12
0
        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);
        }
예제 #13
0
        private void CreatePacket(object userData, string[] options, int selected)
        {
            if (selected == 0)
            {
                CurrentPacket = new OSCMessage("/address");
            }
            else
            {
                CurrentPacket = new OSCBundle();
            }

            FilePath = string.Empty;
        }
예제 #14
0
        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);
        }
예제 #15
0
        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);
        }
예제 #16
0
        /// <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;
 }
예제 #18
0
        public static void OpenPacket(IOSCPacket packet)
        {
            Open();

            Instance._packetEditorPanel.CurrentPacket = packet.Copy();
        }
예제 #19
0
 public static string GeneratePacket(IOSCPacket packet)
 {
     return(packet.IsBundle() ? GenerateBundle(packet as OSCBundle) : GenerateMessage(packet as OSCMessage));
 }
예제 #20
0
        public static string ToBase64String(IOSCPacket packet)
        {
            var length = OSCConverter.Pack(packet, out var buffer);

            return(Convert.ToBase64String(buffer, 0, length));
        }