Exemple #1
0
    public void WriteBuffer(byte[] buffer, int offset, int length)
    {
        Debug.Log("luckyhigh start to write");
        if (fs == null)
        {
            return;
        }

        Debug.Log("luckyhigh fs is no null");

        int temp = offset - length;

        byte[] tempBuf = new byte[length];
        Array.Copy(buffer, temp, tempBuf, 0, length);
        double TimeOffset = (DateTime.Now - firstTime).TotalMilliseconds;

        NetMsg net = new NetMsg();

        net.offset = TimeOffset;
        net.buffer = new List <byte>(tempBuf);

        byte[] data = ProtoUtil.JceStructToBytes(net);

        byte[] _len = BitConverter.GetBytes((ushort)(data.Length + PACKAGE_HEADER_SIZE));

        if (BitConverter.IsLittleEndian)
        {
            Array.Reverse(_len);
        }

        byte[] _bufferWithLen = new byte[_len.Length + data.Length];
        _len.CopyTo(_bufferWithLen, 0);
        data.CopyTo(_bufferWithLen, _len.Length);

        Debug.Log("luckyhigh offset " + TimeOffset + " data Len " + data.Length + " total len " + _bufferWithLen.Length);

        fs.Write(_bufferWithLen, 0, (int)_bufferWithLen.Length);
        fs.Flush();
    }