C# Class GonzoNet.PacketStream

A readable and writable packet.
Inheritance: Stream
Mostra file Open project: RHY3756547/FreeSO Class Usage Examples

Public Properties

Property Type Description
m_VariableLength bool

Protected Properties

Property Type Description
m_BaseStream System.IO.MemoryStream
m_Length int
m_Reader System.IO.BinaryReader

Public Methods

Method Description
Flush ( ) : void

Flushes the underlying stream.

PacketStream ( byte ID, int Length ) : System

Constructs a new PacketStream instance to write to.

PacketStream ( byte ID, int Length, byte DataBuffer ) : System

Constructs a new PacketStream instance to read from.

PeekByte ( ) : byte

Peeks a byte from the stream at the current position.

PeekByte ( int Position ) : byte

Peeks a byte from the stream at the specified position.

PeekInt ( int Position ) : int

Peeks an int from the stream at the specified position.

PeekUShort ( int Position ) : ushort

Peeks a ushort from the stream at the specified position.

Read ( byte buffer, int offset, int count ) : int

Reads a specific number of bytes from this PacketStream.

ReadByte ( ) : int

Reads a byte from this PacketStream instance.

ReadBytes ( int NumBytes ) : byte[]

Reads a specific number of bytes from this PacketStream.

ReadDouble ( ) : double

Reads a double from this PacketStream instance.

ReadInt32 ( ) : int

Reads an integer from this PacketStream instance.

ReadInt64 ( ) : long

Reads a long integer from this PacketStream instance.

ReadString ( ) : string

Reads a string from this PacketStream instance.

ReadString ( int NumChars ) : string

Reads a string from this PacketStream instance.

ReadUInt16 ( ) : ushort

Reads a short from this PacketStream instance.

ReadUInt64 ( ) : ulong

Reads an unsigned long integer from this PacketStream instance.

ReadUShort ( ) : ushort

Reads a ushort from this PacketStream instance.

Seek ( long offset, SeekOrigin origin ) : long

Do not call this! It will throw a NotImplementedException!

SetLength ( long value ) : void

Sets the length of this PacketStream to the specified value.

ToArray ( ) : byte[]

Creates an array of bytes with the data in this PacketStream instance.

Write ( byte buffer, int offset, int count ) : void

Writes a block of bytes to this PacketStream instance.

WriteByte ( byte Value ) : void

Writes a byte to this PacketStream instance.

WriteBytes ( byte Buffer ) : void

Writes a block of bytes to this PacketStream instance.

WriteDouble ( double Value ) : void

Writes a 64 bit double to this PacketStream instance.

WriteHeader ( ) : void

Writes the packet header.

WriteInt32 ( int Value ) : void

Writes a 32 bit integer to this PacketStream instance.

WriteInt64 ( long Value ) : void

Writes a 64 bit integer to this PacketStream instance.

WriteString ( string Str ) : void
WriteUInt16 ( ushort Value ) : void

Writes an unsigned short to this PacketStream instance.

WriteUInt64 ( ulong Value ) : void

Writes an unsigned 64 bit integer to this PacketStream instance.

Method Details

Flush() public method

Flushes the underlying stream.
public Flush ( ) : void
return void

PacketStream() public method

Constructs a new PacketStream instance to write to.
public PacketStream ( byte ID, int Length ) : System
ID byte The ID of this PacketStream instance.
Length int The length of this PacketStream instance (0 if variable length).
return System

PacketStream() public method

Constructs a new PacketStream instance to read from.
public PacketStream ( byte ID, int Length, byte DataBuffer ) : System
ID byte The ID of this PacketStream instance.
Length int The length of this PacketStream instance.
DataBuffer byte The buffer from which to create this PacketStream instance.
return System

PeekByte() public method

Peeks a byte from the stream at the current position.
public PeekByte ( ) : byte
return byte

PeekByte() public method

Peeks a byte from the stream at the specified position.
public PeekByte ( int Position ) : byte
Position int The position to peek at.
return byte

PeekInt() public method

Peeks an int from the stream at the specified position.
public PeekInt ( int Position ) : int
Position int The position to peek at.
return int

PeekUShort() public method

Peeks a ushort from the stream at the specified position.
public PeekUShort ( int Position ) : ushort
Position int The position to peek at.
return ushort

Read() public method

Reads a specific number of bytes from this PacketStream.
public Read ( byte buffer, int offset, int count ) : int
buffer byte The buffer to read into.
offset int The zero-based byte offset in buffer at which to begin storing data from the current stream.
count int The number of bytes to read (must be at least equal to the length of buffer!)
return int

ReadByte() public method

Reads a byte from this PacketStream instance.
public ReadByte ( ) : int
return int

ReadBytes() public method

Reads a specific number of bytes from this PacketStream.
public ReadBytes ( int NumBytes ) : byte[]
NumBytes int Number of bytes to read.
return byte[]

ReadDouble() public method

Reads a double from this PacketStream instance.
public ReadDouble ( ) : double
return double

ReadInt32() public method

Reads an integer from this PacketStream instance.
public ReadInt32 ( ) : int
return int

ReadInt64() public method

Reads a long integer from this PacketStream instance.
public ReadInt64 ( ) : long
return long

ReadString() public method

Reads a string from this PacketStream instance.
public ReadString ( ) : string
return string

ReadString() public method

Reads a string from this PacketStream instance.
public ReadString ( int NumChars ) : string
NumChars int
return string

ReadUInt16() public method

Reads a short from this PacketStream instance.
public ReadUInt16 ( ) : ushort
return ushort

ReadUInt64() public method

Reads an unsigned long integer from this PacketStream instance.
public ReadUInt64 ( ) : ulong
return ulong

ReadUShort() public method

Reads a ushort from this PacketStream instance.
public ReadUShort ( ) : ushort
return ushort

Seek() public method

Do not call this! It will throw a NotImplementedException!
public Seek ( long offset, SeekOrigin origin ) : long
offset long The offset to seek to.
origin SeekOrigin The origin of the seek.
return long

SetLength() public method

Sets the length of this PacketStream to the specified value.
public SetLength ( long value ) : void
value long The length of the stream.
return void

ToArray() public method

Creates an array of bytes with the data in this PacketStream instance.
public ToArray ( ) : byte[]
return byte[]

Write() public method

Writes a block of bytes to this PacketStream instance.
public Write ( byte buffer, int offset, int count ) : void
buffer byte The data to write.
offset int The offset at which to start writing.
count int The maximum number of bytes to write.
return void

WriteByte() public method

Writes a byte to this PacketStream instance.
public WriteByte ( byte Value ) : void
Value byte The byte to write.
return void

WriteBytes() public method

Writes a block of bytes to this PacketStream instance.
public WriteBytes ( byte Buffer ) : void
Buffer byte The data to write.
return void

WriteDouble() public method

Writes a 64 bit double to this PacketStream instance.
public WriteDouble ( double Value ) : void
Value double The 64 bit double to write.
return void

WriteHeader() public method

Writes the packet header.
public WriteHeader ( ) : void
return void

WriteInt32() public method

Writes a 32 bit integer to this PacketStream instance.
public WriteInt32 ( int Value ) : void
Value int The 32 bit integer to write.
return void

WriteInt64() public method

Writes a 64 bit integer to this PacketStream instance.
public WriteInt64 ( long Value ) : void
Value long The 64 bit integer to write.
return void

WriteString() public method

public WriteString ( string Str ) : void
Str string
return void

WriteUInt16() public method

Writes an unsigned short to this PacketStream instance.
public WriteUInt16 ( ushort Value ) : void
Value ushort The unsigned short to write.
return void

WriteUInt64() public method

Writes an unsigned 64 bit integer to this PacketStream instance.
public WriteUInt64 ( ulong Value ) : void
Value ulong The unsigned 64 bit integer to write.
return void

Property Details

m_BaseStream protected_oe property

protected MemoryStream,System.IO m_BaseStream
return System.IO.MemoryStream

m_Length protected_oe property

protected int m_Length
return int

m_Reader protected_oe property

protected BinaryReader,System.IO m_Reader
return System.IO.BinaryReader

m_VariableLength public_oe property

public bool m_VariableLength
return bool