Osc.ExtractMessages C# (CSharp) Method

ExtractMessages() private static method

Receive a raw packet of bytes and extract OscMessages from it. Used internally.
The packet may contain a OSC message or a bundle of messages.
private static ExtractMessages ( ArrayList messages, byte packet, int start, int length ) : int
messages ArrayList An ArrayList to be populated with the OscMessages.
packet byte The packet of bytes to be parsed.
start int The index of where to start looking in the packet.
length int The length of the packet.
return int
    private static int ExtractMessages(ArrayList messages, byte[] packet, int start, int length)
    {
      int index = start;
      switch ( (char)packet[ start ] )
      {
        case '/':
          index = ExtractMessage( messages, packet, index, length );
          break;
        case '#':
          string bundleString = ExtractString(packet, start, length);
          if ( bundleString == "#bundle" )
          {
            // skip the "bundle" and the timestamp
            index+=16;
            while ( index < length )
            {
              int messageSize = ( packet[index++] << 24 ) + ( packet[index++] << 16 ) + ( packet[index++] << 8 ) + packet[index++];
              /*int newIndex = */ExtractMessages( messages, packet, index, length ); 
              index += messageSize;
            }            
          }
          break;
      }
      return index;
    }