Ejemplo n.º 1
0
        /// <summary>
        /// Add a osc message to the send queue
        /// </summary>
        /// <param name="message">message to send</param>
        public void Send(OscPacket message)
        {
            if (State != OscSocketState.Connected)
            {
                return;
            }

            queueEmpty.Reset();

            if (sendQueue.Count >= messageBufferSize)
            {
                return;
            }

            sendQueue.Enqueue(message);

            if (sendQueue.Count != 1)
            {
                return;
            }

            int size = message.Write(buffer);

            if (Statistics != null)
            {
                message.IncrementSendStatistics(Statistics);

                Statistics.BytesSent.Increment(size);
            }

            PacketSent?.Invoke(message);

            Socket.BeginSend(buffer, 0, size, SocketFlags, Send_Callback, message);
        }
Ejemplo n.º 2
0
        public void Send(OscPacket packet)
        {
            if (Statistics != null)
            {
                packet.IncrementSendStatistics(Statistics);
            }

            writer.Write(packet);
            file.Flush();
        }
Ejemplo n.º 3
0
        public void Send(OscPacket packet)
        {
            if (serialPort == null)
            {
                throw new Exception("Serial port is not connected");
            }

            byte[] packetBytes  = packet.ToByteArray();
            byte[] slippedBytes = SlipPacketWriter.Write(packetBytes, 0, packetBytes.Length);

            if (Statistics != null)
            {
                packet.IncrementSendStatistics(Statistics);

                Statistics.BytesSent.Increment(packetBytes.Length);
            }

            serialPort.Write(slippedBytes, 0, slippedBytes.Length);
        }