SharpOSC.OscPacket.GetPacket C# (CSharp) Méthode

GetPacket() public static méthode

public static GetPacket ( byte OscData ) : OscPacket
OscData byte
Résultat OscPacket
        public static OscPacket GetPacket(byte[] OscData)
        {
            if (OscData[0] == '#')
                return parseBundle(OscData);
            else
                return parseMessage(OscData);
        }

Usage Example

Exemple #1
0
        void ReceiveCallback(IAsyncResult result)
        {
            Monitor.Enter(callbackLock);
            Byte[] bytes = null;

            IPEndPoint remoteEP = null;

            try
            {
                bytes = receivingUdpClient.EndReceive(result, ref remoteEP);
            }
            catch (ObjectDisposedException e)
            {
                // Ignore if disposed. This happens when closing the listener
            }

            // Process bytes
            if (bytes != null && bytes.Length > 0)
            {
                if (BytePacketCallback != null)
                {
                    BytePacketCallback(bytes);
                }
                else if (OscPacketCallback != null)
                {
                    OscPacket packet = null;
                    try
                    {
                        packet = OscPacket.GetPacket(bytes, remoteEP);
                    }
                    catch (Exception e)
                    {
                        // If there is an error reading the packet, null is sent to the callback
                    }

                    OscPacketCallback(packet);
                }
                else
                {
                    lock (queue)
                    {
                        queue.Enqueue(bytes);
                    }
                }
            }

            if (closing)
            {
                ClosingEvent.Set();
            }
            else
            {
                // Setup next async event
                AsyncCallback callBack = new AsyncCallback(ReceiveCallback);
                receivingUdpClient.BeginReceive(callBack, remoteEP);
            }
            Monitor.Exit(callbackLock);
        }
All Usage Examples Of SharpOSC.OscPacket::GetPacket