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

An Attribute that stores an numeric error code and string error message. More...

Inherits NobleConnect.Stun.Attribute.

Public Member Functions

 AttributeErrorCode (AttributeType attributeType, ushort errorCode, string errorMessage)
 Construct an AttributeErrorCode of the provided AttributeType using the provided error code and message More...
 
 AttributeErrorCode (AttributeType type, byte[] buffer, ref int offset)
 Construct an AttributeErrorCode from the provided byte array More...
 
override void SerializeValues (BufferView buffer, ReadOnlyByteArray transactionID)
 Transform the string into an ArraySegment of bytes to be sent over the network. More...
 
override ushort GetValueSize ()
 Get the serialized size of the attribute values More...
 
- Public Member Functions inherited from NobleConnect.Stun.Attribute
 Attribute (AttributeType type)
 Construct an Attribute of the provided AttributeType More...
 
 Attribute (AttributeType type, ref int offset)
 
void Serialize (BufferView buffer, ReadOnlyByteArray transactionID)
 Convert this attribute to a bunch of bytes and add them to the provided buffer More...
 
ushort GetSize ()
 

Public Attributes

readonly ushort errorCode
 The numeric error code. More...
 
readonly string errorMessage
 A human readable error message More...
 
- Public Attributes inherited from NobleConnect.Stun.Attribute
readonly AttributeType attributeType
 The AttributeType of this Attribute More...
 

Additional Inherited Members

- Static Public Member Functions inherited from NobleConnect.Stun.Attribute
static ushort DeserializeLength (byte[] buffer, ref int offset)
 Read the Attribute length from a byte array. More...
 
static ushort GetNumPaddingBytes (int length)
 Calculate padding based on length More...
 
- Static Public Attributes inherited from NobleConnect.Stun.Attribute
const int HEADER_SIZE = 4
 

Detailed Description

An Attribute that stores an numeric error code and string error message.

The error code is weirdly encoded as described below but you don't really need to know about that to use this class. Once the errorCode is decoded it is a 3 digit number between 300 and 699.

See RFC 5389 Section 15.6 for details on specific error codes.

0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Reserved, should be 0 |Class| Number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Reason Phrase(variable) .. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

The class of the error code (the hundreds digit) is encoded separately from the rest of the code, as shown in the diagram. The Reserved bits are ignored and are for 32bit alignment The Class represents the hundreds digit of the error code. The value is be between 3 and 6. The Number represents the error code modulo 100, and its value is be between 0 and 99.

Constructor & Destructor Documentation

◆ AttributeErrorCode() [1/2]

NobleConnect.Stun.AttributeErrorCode.AttributeErrorCode ( AttributeType  attributeType,
ushort  errorCode,
string  errorMessage 
)

Construct an AttributeErrorCode of the provided AttributeType using the provided error code and message

This is called when constructing an Attribute to send to a Stun server.

Parameters
attributeType
errorCode
errorMessage

◆ AttributeErrorCode() [2/2]

NobleConnect.Stun.AttributeErrorCode.AttributeErrorCode ( AttributeType  type,
byte[]  buffer,
ref int  offset 
)

Construct an AttributeErrorCode from the provided byte array

This is called when deserializing an AttributeErrorCode received from a Stun server.

Parameters
type
buffer
offset

Member Function Documentation

◆ GetValueSize()

override ushort NobleConnect.Stun.AttributeErrorCode.GetValueSize ( )
virtual

Get the serialized size of the attribute values

Returns
2 for the skipped bytes plus 1 for the errorClass plus 1 for the errorNumber plus the byte length of the URF8 encoded errorMessage.

Reimplemented from NobleConnect.Stun.Attribute.

◆ SerializeValues()

override void NobleConnect.Stun.AttributeErrorCode.SerializeValues ( BufferView  buffer,
ReadOnlyByteArray  transactionID 
)
virtual

Transform the string into an ArraySegment of bytes to be sent over the network.

Uses UTF8 encoding

Reimplemented from NobleConnect.Stun.Attribute.

Member Data Documentation

◆ errorCode

readonly ushort NobleConnect.Stun.AttributeErrorCode.errorCode

The numeric error code.

See RFC 5389 Section 15.6 for details on specific error codes.

◆ errorMessage

readonly string NobleConnect.Stun.AttributeErrorCode.errorMessage

A human readable error message