Ejemplo n.º 1
0
        private void OnNetworkPreparePacket(IPEndPoint remote, byte[] bytes, ref int offset, int count)
        {
            var packet = new AudioPacket();

            if (!packet.TryUnpack(bytes, ref offset, count))
            {
                return;
            }

            Received?.Invoke(remote, packet);
        }
Ejemplo n.º 2
0
        private void OnTransportReceived(byte[] bytes, ref int offset, int count)
        {
            var packet = new AudioPacket();

            while (packet.TryUnpack(bytes, ref offset, count))
            {
                if (!_routes.TryGetValue(packet.RouteId, out AudioRoute route))
                {
                    continue;
                }

                route.Handle(packet);
            }
        }
Ejemplo n.º 3
0
        public void Unpack_Correct_Success()
        {
            // Arrange
            var offset = 0;

            Pack_Correct_Success();

            // Act
            var result = _packet.TryUnpack(_packetBytes, ref offset, _packetBytes.Length);

            // Assert
            Assert.AreEqual(true, result);
            Assert.AreEqual(14, offset);
            Assert.AreEqual(100, _packet.RouteId);
            Assert.AreEqual(true, _packet.Mark);
            Assert.AreEqual(200, _packet.SequenceId);
            CollectionAssert.AreEqual(new byte[] { 1, 2, 3 }, _packet.Payload);
        }