Noble Connect
Add relays and punchthrough to Mirror or UNet
NobleConnect.BufferView Class Reference

Stores a list of ArraySegments of bytes to be sent over a socket. More...

Public Member Functions

void Add (ArraySegment< byte > entry)
 Add an ArraySegment to the Buffer More...
 
void Add (byte[] bytes)
 Wrap the provided byte array in an ArraySegment and add it to the Buffer More...
 
long CopyToArray (ArraySegment< byte > output)
 
long CopyToArray (byte[] output, long offset=0, long count=-1)
 Convert a Buffer to a flat byte array. More...
 

Properties

long Length [get]
 The total length in bytes of all ArraySegments in the buffer More...
 

Detailed Description

Stores a list of ArraySegments of bytes to be sent over a socket.

Add bytes or ArraySegments to the BufferView using the Add() methods and then send the BufferView over a socket using the Send() method.

The list of ArraySegments can never be accessed directly. This is to ensure that the backing arrays are only read from to maintain thread-safety.

If you need a mutable copy of the bytes from the buffer you can use the CopyToArray() method.

Member Function Documentation

◆ Add() [1/2]

void NobleConnect.BufferView.Add ( ArraySegment< byte >  entry)

Add an ArraySegment to the Buffer

Parameters
entry

◆ Add() [2/2]

void NobleConnect.BufferView.Add ( byte[]  bytes)

Wrap the provided byte array in an ArraySegment and add it to the Buffer

Parameters
bytes

◆ CopyToArray() [1/2]

long NobleConnect.BufferView.CopyToArray ( ArraySegment< byte >  output)

◆ CopyToArray() [2/2]

long NobleConnect.BufferView.CopyToArray ( byte[]  output,
long  offset = 0,
long  count = -1 
)

Convert a Buffer to a flat byte array.

Parameters
buffer
Returns

Property Documentation

◆ Length

long NobleConnect.BufferView.Length
get

The total length in bytes of all ArraySegments in the buffer