Monkey Documentation

Class Packet

Packet objects act as standard Stream objects, providing structured memory manipulation. More...


Extends:
  • PublicDataStream
Extended by:
Constants:
  • Default_BigEndianStorage : Bool
Constructors:
  • New ( Size:Int, FixByteOrder:Bool=default_bigendianstorage, AutoClose:Bool=true )
  • New ( Message:String, Encoding:String="utf8", FixByteOrder:Bool=default_bigendianstorage, AutoClose:Bool=true )
Properties:
Methods:
Functions:

Detailed Discussion

Packet objects act as standard Stream objects, providing structured memory manipulation. They are seekable, and used both internally and externally. Closing a Packet allocated by a NetworkEngine is considered bad practice, and will result in unstable behavior if released formally.

Constructor Documentation

Method New ( Size:Int, FixByteOrder:Bool=default_bigendianstorage, AutoClose:Bool=true )

  • The Size argument specifies the maximum size of this Packet.
  • The FixByteOrder argument determines if byte-swapping will be used.
  • The AutoClose argument specifies if a call to Release is allowed to close this packet-stream.

Method New ( Message:String, Encoding:String="utf8", FixByteOrder:Bool=default_bigendianstorage, AutoClose:Bool=true )

  • The Message argument specifies the message-data initially provided to this Packet. Packet objects are not currently resizable, so this will represent the entire message.
  • The Encoding argument specifies the standard encoding mode; see PokeString for details.
  • The FixByteOrder argument determines if byte-swapping will be used.
Like the other overload(s), the AutoClose argument specifies if Release is allowed to close this packet-stream.


Property Documentation

Method AutoClose : Bool () Property

This corresponds to the 'AutoClose' argument in the constructor(s). See also: New

Method IsReliable : Bool () Property

This specifies if this is a reliable packet. (Used internally; always False for normal Packet objects)

Method Released : Bool () Property

This specifies if the internal reference-counter is zero.


Method Documentation

Method ForceReset : Void ()

This is used internally, and is used to force a Packet to reset its meta-data.

Method Obtain : Void ()

This is used to "obtain a reference" (Increment a reference counter) to this Packet. When finished using a Packet after calling this, please call Reset. Do not call this unless you intend to keep a Packet alive. Calling ReleasePacket before calling Reset is considered bad practice. See also: Reset, ForceReset

Method Release : Bool ()

Unlike a pool, this does not handle re-use. This will decrement the internal reference-counter. If that counter hits zero, this will perform a Close operation. Because of this, calling Release is considered unsafe, and should be avoided unless you intend to manage packets yourself. The return-value of this method specifies if this packet is no longer referenced. See also: Obtain, Reset, ForceReset

Method Reset : Void ()

This is used to decrement the internal reference-counter. When all references are relinquished, this will call ForceReset. This is mostly an internal routine; use at your own risk. If you intend to manage Packet objects yourself, this can be useful. But, if you're using pre-generated Packets from a NetworkEngine, use ReleasePacket (Or similar) instead. See also: Obtain, ForceReset


Function Documentation

Function SizeOfString : Int ( S:String )

An internal function used to retrieve the projected (Serialized) size of S.