Beispiel #1
0
        /// <summary>
        /// Reads a value from the packet
        /// </summary>
        /// <returns>value</returns>
        public ushort ReadUShort()
        {
            ushort res = ByteManipulator.ReadUInt16(Data, CurrentSeek);

            CurrentSeek += sizeof(ushort);
            return(res);
        }
    public void TestSendToAllOthersCorrectFrequencyRedLight()
    {
        VoicePacketInfo info = new VoicePacketInfo();

        info.Frequency = 5666;
        transport.SendToAll(new BytePacket(1), info, new List <ulong>()
        {
            1
        });
        Assert.That(ByteManipulator.ReadUInt16(workflow.receivedData, 0), Is.Not.EqualTo(17898));
    }
Beispiel #3
0
    public void TestListUshortReadRedLight()
    {
        List <byte> arr = new List <byte>(sizeof(ushort));

        for (int i = 0; i < sizeof(ushort); i++)
        {
            arr.Add(0);
        }
        ByteManipulator.Write(arr, 0, (ushort)25);
        Assert.That(ByteManipulator.ReadUInt16(arr, 0), Is.Not.EqualTo(9));
    }
    public void TestSendToAllOthersCorrectPayloadData2RedLight()
    {
        BytePacket p = new BytePacket(10);

        p.Write(750);
        p.Write((ushort)110);
        p.Write((sbyte)-5);
        p.Write(false);
        p.Write((short)short.MinValue);
        p.CurrentSeek = 0;
        transport.SendToAll(p, new VoicePacketInfo(), new List <ulong>()
        {
            1
        });
        Assert.That(ByteManipulator.ReadUInt16(workflow.receivedData, 8), Is.Not.EqualTo(10));
    }
Beispiel #5
0
        /// <summary>
        /// Process packet data
        /// </summary>
        /// <param name="buffer">GamePacket of which data will be stored</param>
        /// <param name="dataReceived">Raw data received from network</param>
        /// <param name="startIndex">Raw data start index</param>
        /// <param name="length">Raw data length</param>
        /// <param name="netId">Sender net id</param>
        /// <returns>data info</returns>
        public override VoicePacketInfo ProcessReceivedData(BytePacket buffer, byte[] dataReceived, int startIndex, int length, ulong netId)
        {
            VoicePacketInfo info = new VoicePacketInfo();

            info.Frequency       = ByteManipulator.ReadUInt16(dataReceived, startIndex);
            startIndex          += sizeof(ushort);
            info.Channels        = ByteManipulator.ReadByte(dataReceived, startIndex);
            startIndex          += sizeof(byte);
            info.Format          = (AudioDataTypeFlag)ByteManipulator.ReadByte(dataReceived, startIndex);
            startIndex          += sizeof(byte);
            info.ValidPacketInfo = true;

            buffer.WriteByteData(dataReceived, startIndex, length - sizeof(ushort) - sizeof(byte) - sizeof(byte));

            return(info);
        }
Beispiel #6
0
 public void TestUshortReadRedLight()
 {
     byte[] arr = new byte[sizeof(ushort)];
     ByteManipulator.Write(arr, 0, (ushort)25);
     Assert.That(ByteManipulator.ReadUInt16(arr, 0), Is.Not.EqualTo(9));
 }
Beispiel #7
0
 public void TestUshortRead()
 {
     byte[] arr = new byte[sizeof(ushort)];
     ByteManipulator.Write(arr, 0, (ushort)60001);
     Assert.That(ByteManipulator.ReadUInt16(arr, 0), Is.EqualTo(60001));
 }