/// <summary>
 ///   Creates a I/O event argument object which contains an OSC message.
 /// </summary>
 public OscIoDeviceEventArgs(OscMessage message,
                             OscIoDeviceChannel deviceChannel,
                             Exception exception = null)
 {
     Message = message;
     DeviceChannel = deviceChannel;
     Exception = exception;
 }
        /// <summary>
        ///   Sends an OSC message to the given UDP address.
        /// </summary>
        public void Send(OscMessage message,
                         OscIoDeviceChannel deviceChannel)
        {
            if (ReferenceEquals(message, null))
                throw new ArgumentNullException("message");

            byte[] packet = message.ToOscPacketArray();
            IPEndPoint ipEndPoint = deviceChannel != null ? deviceChannel.IPEndPoint : _defaultRemoteEndPoint;
            OscIoDeviceEventArgs eventArgs = new OscIoDeviceEventArgs(message,
                                                                      new OscIoDeviceChannel(
                                                                          OscIoDeviceChannelType.Udp,
                                                                          ipEndPoint));
            // send message
            _udp.BeginSend(packet, packet.Length, ipEndPoint, OnSend, eventArgs);
        }
        /// <summary>
        ///   Parses a message packet.
        /// </summary>
        private static OscMessage ParseMessage(byte[] packet)
        {
            int packetIndex = 0;

            OscMessage msg = new OscMessage
                                 {
                                     Address = ParseAddress(packet, ref packetIndex),
                                     Arguments =
                                         ParseArguments(packet, ref packetIndex)
                                 };

            return msg;
        }