public void TransportPacket(Who recipient, FlexBuffer buf) { // Data-ize the packet // assert index is at the start of the header. int dataSize = buf.Avail(); if (dataSize < HEADER_SIZE) { throw new ArgumentException("dataSize < HEADER_SIZE"); } int pktSize = dataSize - HEADER_SIZE; if (maxPktSize > 0 && pktSize > maxPktSize) { throw new ArgumentException("maxPktSize > 0 && pktSize > maxPktSize"); } int index = buf.Index(); buf.PutInt(SIG); buf.PutInt(pktSize); buf.SetIndex(index); transport.TransportData(recipient, buf); }
public void PutInt2() { int max = 4 * 1024 * 1024; buf = new FlexBuffer(new byte[max]); buf.SetIndex(max); buf.PutInt(int.MinValue); CheckBuf(max + 4, max + 4, 0); }
public void PutInt1() { buf = new FlexBuffer(new byte[] { }); buf.PutInt(int.MaxValue); CheckBuf(4, 4, 0); buf.SetIndex(0); Assert.AreEqual(int.MaxValue, buf.GetInt()); CheckBuf(4, 4, 0); }