TNet 3  3.0.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
TNet.Buffer Class Reference

This class merges BinaryWriter and BinaryReader into one. More...

Public Member Functions

bool Recycle ()
 Release the buffer into the reusable pool. More...
 
void MarkAsUsed ()
 Mark the buffer as being in use. More...
 
void Clear ()
 Clear the buffer. More...
 
void CopyTo (Buffer target)
 Copy the contents of this buffer into the target one, trimming away unused space. More...
 
BinaryWriter BeginWriting (bool append=false)
 Begin the writing process. More...
 
BinaryWriter BeginWriting (int startOffset)
 Begin the writing process, appending from the specified offset. More...
 
int EndWriting ()
 Finish the writing process, returning the packet's size. More...
 
BinaryReader BeginReading ()
 Begin the reading process. More...
 
BinaryReader BeginReading (int startOffset)
 Begin the reading process. More...
 
int PeekByte (int pos)
 Peek at the first byte at the specified offset. More...
 
int PeekInt (int pos)
 Peek at the first integer at the specified offset. More...
 
byte[] PeekBytes (int pos, int length)
 Peek-read the specified number of bytes. More...
 
BinaryWriter BeginPacket (byte packetID)
 Begin writing a packet: the first 4 bytes indicate the size of the data that will follow. More...
 
BinaryWriter BeginPacket (Packet packet)
 Begin writing a packet: the first 4 bytes indicate the size of the data that will follow. More...
 
BinaryWriter BeginPacket (Packet packet, int startOffset)
 Begin writing a packet: the first 4 bytes indicate the size of the data that will follow. More...
 
int EndPacket ()
 Finish writing of the packet, updating (and returning) its size. More...
 
int EndTcpPacketStartingAt (int startOffset)
 Finish writing of the packet, updating (and returning) its size. More...
 
int EndTcpPacketWithOffset (int offset)
 Finish writing the packet and reposition the stream's position to the specified offset. More...
 

Static Public Member Functions

static Buffer Create ()
 Create a new buffer, reusing an old one if possible. More...
 
static void Recycle (Queue< Buffer > list)
 Recycle an entire queue of buffers. More...
 
static void Recycle (Queue< Datagram > list)
 Recycle an entire queue of buffers. More...
 
static void Recycle (List< Buffer > list)
 Recycle an entire list of buffers. More...
 
static void Recycle (List< Datagram > list)
 Recycle an entire list of buffers. More...
 
static void ReleaseUnusedMemory ()
 Release all currently unused memory sitting in the memory pool. More...
 

Properties

int size [get]
 The size of the data present in the buffer. More...
 
int position [get, set]
 Position within the stream. More...
 
MemoryStream stream [get]
 Underlying memory stream. More...
 
byte[] buffer [get]
 Get the entire buffer (note that it may be bigger than 'size'). More...
 
static int recycleQueue [get]
 Number of buffers in the recycled list. More...
 

Detailed Description

This class merges BinaryWriter and BinaryReader into one.

Member Function Documentation

BinaryWriter TNet.Buffer.BeginPacket ( byte  packetID)

Begin writing a packet: the first 4 bytes indicate the size of the data that will follow.

BinaryWriter TNet.Buffer.BeginPacket ( Packet  packet)

Begin writing a packet: the first 4 bytes indicate the size of the data that will follow.

BinaryWriter TNet.Buffer.BeginPacket ( Packet  packet,
int  startOffset 
)

Begin writing a packet: the first 4 bytes indicate the size of the data that will follow.

BinaryReader TNet.Buffer.BeginReading ( )

Begin the reading process.

BinaryReader TNet.Buffer.BeginReading ( int  startOffset)

Begin the reading process.

BinaryWriter TNet.Buffer.BeginWriting ( bool  append = false)

Begin the writing process.

BinaryWriter TNet.Buffer.BeginWriting ( int  startOffset)

Begin the writing process, appending from the specified offset.

void TNet.Buffer.Clear ( )

Clear the buffer.

void TNet.Buffer.CopyTo ( Buffer  target)

Copy the contents of this buffer into the target one, trimming away unused space.

static Buffer TNet.Buffer.Create ( )
static

Create a new buffer, reusing an old one if possible.

int TNet.Buffer.EndPacket ( )

Finish writing of the packet, updating (and returning) its size.

int TNet.Buffer.EndTcpPacketStartingAt ( int  startOffset)

Finish writing of the packet, updating (and returning) its size.

int TNet.Buffer.EndTcpPacketWithOffset ( int  offset)

Finish writing the packet and reposition the stream's position to the specified offset.

int TNet.Buffer.EndWriting ( )

Finish the writing process, returning the packet's size.

void TNet.Buffer.MarkAsUsed ( )

Mark the buffer as being in use.

int TNet.Buffer.PeekByte ( int  pos)

Peek at the first byte at the specified offset.

byte [] TNet.Buffer.PeekBytes ( int  pos,
int  length 
)

Peek-read the specified number of bytes.

int TNet.Buffer.PeekInt ( int  pos)

Peek at the first integer at the specified offset.

bool TNet.Buffer.Recycle ( )

Release the buffer into the reusable pool.

static void TNet.Buffer.Recycle ( Queue< Buffer list)
static

Recycle an entire queue of buffers.

static void TNet.Buffer.Recycle ( Queue< Datagram list)
static

Recycle an entire queue of buffers.

static void TNet.Buffer.Recycle ( List< Buffer list)
static

Recycle an entire list of buffers.

static void TNet.Buffer.Recycle ( List< Datagram list)
static

Recycle an entire list of buffers.

static void TNet.Buffer.ReleaseUnusedMemory ( )
static

Release all currently unused memory sitting in the memory pool.

Property Documentation

byte [] TNet.Buffer.buffer
get

Get the entire buffer (note that it may be bigger than 'size').

int TNet.Buffer.position
getset

Position within the stream.

int TNet.Buffer.recycleQueue
staticget

Number of buffers in the recycled list.

int TNet.Buffer.size
get

The size of the data present in the buffer.

MemoryStream TNet.Buffer.stream
get

Underlying memory stream.


The documentation for this class was generated from the following file: