Microsoft.Xna.Framework.Net
Class PacketReader

java.lang.Object
  extended by System.IO.BinaryReader
      extended by Microsoft.Xna.Framework.Net.PacketReader
All Implemented Interfaces:
IDisposable

public class PacketReader
extends BinaryReader

Provides common functionality for efficiently reading incoming network packets. Reference page contains links to related code samples.

Author:
Halofreak1990

Constructor Summary
PacketReader()
          Initializes an empty instance of PacketReader.
PacketReader(int capacity)
          Initializes an empty instance of PacketReader with the specified options.
 
Method Summary
 int getPosition()
          Gets the current packet read position.
 int Length()
          Gets the length of the packet being read.
 Color ReadColor()
          Reads a Color value.
 double ReadDouble()
          Reads an 8-byte floating point value.
 Matrix ReadMatrix()
          Reads a Matrix value.
 Quaternion ReadQuaternion()
          Reads a Quaternion value.
 float ReadSingle()
          Reads a 4-byte floating point value.
 Vector2 ReadVector2()
          Reads a Vector2 value.
 Vector3 ReadVector3()
          Reads a Vector3 value.
 Vector4 ReadVector4()
          Reads a Vector4 value.
 void setPosition(int value)
          Sets the current packet read position.
 
Methods inherited from class System.IO.BinaryReader
Close, Dispose, Dispose, FillBuffer, getBaseStream, PeekChar, Read, Read, Read, Read7BitEncodedInt, ReadBoolean, ReadByte, ReadBytes, ReadChar, ReadChars, ReadInt16, ReadInt32, ReadInt64, ReadString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PacketReader

public PacketReader()
Initializes an empty instance of PacketReader.


PacketReader

public PacketReader(int capacity)
Initializes an empty instance of PacketReader with the specified options.

Parameters:
capacity - Initial capacity for a received network packet.
Method Detail

Length

public int Length()
Gets the length of the packet being read.


getPosition

public int getPosition()
Gets the current packet read position.


setPosition

public void setPosition(int value)
Sets the current packet read position.


ReadColor

public Color ReadColor()
Reads a Color value.


ReadDouble

public double ReadDouble()
Reads an 8-byte floating point value.

Overrides:
ReadDouble in class BinaryReader

ReadMatrix

public Matrix ReadMatrix()
Reads a Matrix value.


ReadQuaternion

public Quaternion ReadQuaternion()
Reads a Quaternion value.


ReadSingle

public float ReadSingle()
Reads a 4-byte floating point value.

Overrides:
ReadSingle in class BinaryReader

ReadVector2

public Vector2 ReadVector2()
Reads a Vector2 value.


ReadVector3

public Vector3 ReadVector3()
Reads a Vector3 value.


ReadVector4

public Vector4 ReadVector4()
Reads a Vector4 value.