Skip to content

bf693aca 19e1 55db 1b2d 6bee6d5279c0

Arthur Frederico Neves edited this page Jul 19, 2016 · 6 revisions

BasePack Class

Is the basic unit of the network communication, in other words all the information that travels over the network is converted in BasePack before transmission and is subsequently reassembled by the receiver. It simplifies operations with the network buffer and handle reading and writing.

Inheritance Hierarchy

System.Object
  NETLIB.BasePack
Namespace: NETLIB
Assembly: NETLIB (in NETLIB.dll) Version: 1.0.0.0 (1.0.0.0)

Syntax

C#

public class BasePack

VB

Public Class BasePack

C++

public ref class BasePack

F#

type BasePack =  class end

The BasePack type exposes the following members.

Constructors

 

Name Description
Public method BasePack() Initialize the inner buffer with packSize
Protected method BasePack(Byte[]) Initialize the BasePack taking buffer as your own inner buffer
Protected method BasePack(BasePack) Takes the basePack inner buffer as its own inner beffer. The readPosition and the writePosition are not copied
  Back to Top

Properties

 

Name Description
Public property Buffer Returns the inner buffer but deny the exchange of buffer reference.
Public property ID Used by IOPackHandler(TPack) to classify and redirect incoming packs to the proper handle function. Refers to the first byte of the buffer.
Public property Item Make the buffer's data public but deny the exchange of buffer reference.
Public property Length Length of the inner buffer.
Public property ReadPosition Gets and sets the readPosition.
Public property WritePosition Gets and sets the writePosition.
  Back to Top

Methods

 

Name Description
Public method DeepCopy Makes a deep copy of the pack, by cloning the internal buffer for the new package.
Public method Equals Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetBool() Converts a part of the inner buffer, started in readPosition, to a bool.
Protected method GetBool(Int32) Converts a part of the inner buffer, started in readPosition, to a bool.
Public method GetByte() Converts a part of the inner buffer, started in readPosition, to a byte.
Protected method GetByte(Int32) Converts a part of the inner buffer, started in readPosition, to a byte.
Public method GetChar() Converts a part of the inner buffer, started in readPosition, to a char.
Protected method GetChar(Int32) Converts a part of the inner buffer, started in readPosition, to a char.
Public method GetDouble() Converts a part of the inner buffer, started in readPosition, to a double.
Protected method GetDouble(Int32) Converts a part of the inner buffer, started in readPosition, to a double.
Public method GetFloat() Converts a part of the inner buffer, started in readPosition, to a float.
Protected method GetFloat(Int32) Converts a part of the inner buffer, started in readPosition, to a float.
Public method GetHashCode Serves as the default hash function. (Inherited from Object.)
Public method GetInt() Converts a part of the inner buffer, started in readPosition, to a int.
Protected method GetInt(Int32) Converts a part of the inner buffer, started in readPosition, to a int.
Public method GetPackable(CustomType) Converts a part of the inner buffer, started in readPosition, to a CustomType.
Public method GetString() Converts a part of the inner buffer, started in readPosition, to a string.
Protected method GetString(Int32) Converts a part of the inner buffer, started in readPosition, to a string.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method PutBool(Boolean) Converts a bool to a byte buffer and put in the inner buffer, started in writePosition
Protected method PutBool(Boolean, Int32) Converts a bool to a byte buffer and put in the inner buffer, started in writePosition
Public method PutByte(Byte) Converts a byte to a byte buffer and put in the inner buffer, started in writePosition
Protected method PutByte(Byte, Int32) Converts a byte to a byte buffer and put in the inner buffer, started in writePosition
Public method PutChar(Char) Converts a char to a byte buffer and put in the inner buffer, started in writePosition
Protected method PutChar(Char, Int32) Converts a char to a byte buffer and put in the inner buffer, started in writePosition
Public method PutDouble(Double) Converts a double to a byte buffer and put in the inner buffer, started in writePosition
Protected method PutDouble(Double, Int32) Converts a double to a byte buffer and put in the inner buffer, started in offset.
Public method PutFloat(Single) Converts a float to a byte buffer and put in the inner buffer, started in writePosition
Protected method PutFloat(Single, Int32) Converts a float to a byte buffer and put in the inner buffer, started in offset.
Public method PutInt(Int32) Converts a int to a byte buffer and put in the inner buffer, started in writePosition
Protected method PutInt(Int32, Int32) Converts a int to a byte buffer and put in the inner buffer, started in offset.
Public method PutPackable(CustomType) Converts a CustomType class that implemets Ipackable to a byte buffet and put in the inner buffer, started in writePosition
Public method PutString(String) Converts a string to a byte buffer and put in the inner buffer, started in writePosition.
Protected method PutString(String, Int32) Converts a string to a byte buffer and put in the inner buffer, started in offset.
Public method Read Copies a sequence of bytes from the pack and advances the current readPosition by the number of bytes copied.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Public method Write Copies a sequence of bytes to the pack and advances the current writePosition by the number of bytes copied.
  Back to Top

Operators

 

Name Description
Public operatorStatic member Implicit(Byte[] to BasePack) Initialize and returns a new BasePack using buffer as it's inner buffer.
  Back to Top

Fields

 

Name Description
Protected field buffer Hold the pack information. Used by Publisher to send the information
Public fieldStatic member packSize Represent the maximum size of the network buffer. The pack buffer will never be bigger than this. Used by Publisher to receive the network buffer
Protected field readPosition Stores the index to be used in the buffer for the next read.
Protected field writePosition Stores the index to be used in the buffer for the next write.
  Back to Top

Examples

The following code example shows how to create a new pack, put and get some fields from there.

void Example()
{
    int d1 = 5;
    int d2 = 6;

    int c1;
    int c2;

    BasePack newPack = new BasePack();
    newPack.ID = 10;
    newPack.PutInt(d1);
    newPack.PutInt(d2);

    c1 = newPack.GetInt();
    c2 = newPack.GetInt();
}

See Also

Reference

NETLIB Namespace

Clone this wiki locally