Monkey Documentation

Class Client

Client objects are "descriptors", specifying how a NetworkEngine can reach an identified node in a network. More...


Fields:
Constructors:
  • New ( Address:NetworkAddress, Connection:Socket=null, PacketConfirmation:Bool=true )
  • New ( Connection:Socket, PacketConfirmation:Bool=false )
Properties:
Methods:

Detailed Discussion

Client objects are "descriptors", specifying how a NetworkEngine can reach an identified node in a network. Client objects are generated, stored, and disclosed by networks (NetworkEngine). References to Client objects are only valid until a network specifies that they are no longer connected/available. These notifications can be interpreted using a ClientNetworkListener (Callback), as specified in the 'networking.engine' module.

Field Documentation

Field ConfirmedPackets : Deque<PacketID>

This is a double-ended queue of confirmed PacketIDs, representing received ReliablePackets.

This field is protected, but is documented for extension purposes.

Field PacketReleaseTimer : TimePoint

This is a "timer" (Point in time) used to calculate the amount of time between PacketID releases from ConfirmedPackets.

This field is protected, but is documented for extension purposes.

Field WaitingMegaPackets : Stack<MegaPacket>

This is a collection of "waiting" (Remotely created) MegaPacket objects.

This field is protected, but is documented for extension purposes.


Constructor Documentation

Method New ( Address:NetworkAddress, Connection:Socket=null, PacketConfirmation:Bool=true )

Constructors for Client objects are handled internally, and should only be used when extending this framework. This overload is used for protocols that are address-based, rather than socket-based. (UDP) That being said, this is also used internally by client NetworkEngine objects, for Remote (Only Client instance).

  • The Address argument specifies the remote address of the client.
  • The Connection argument is mainly available for debugging purposes / internal use.
  • The PacketConfirmation argument is described in Construct_Client.

Method New ( Connection:Socket, PacketConfirmation:Bool=false )

Constructors for Client objects are handled internally, and should only be used when extending this framework. This overload is used for protocols that are socket-based, rather than address-based. (TCP)

  • The Connection argument is used to describe the Socket associated with this client.
  • The PacketConfirmation argument is described in Construct_Client.


Property Documentation

Method Address : NetworkAddress () Property

The address associated with this client; may be Null depending on the underlying transport protocol. (Available for UDP) See also: New

Method Closed : Bool () Property

This specifies if this client handle has been closed by a network and/or user.

Method Closing : Bool () Property

This specifies if this client is in the process of disconnecting/closing. (Ignored for formal messages; only internal messages will be accepted)

Method Closing : Void ( Input:Bool ) Property

Use caution when setting this property-overload. (Handled internally, use at your own risk)

Method Connection : Socket () Property

The Socket associated with this client; may be Null depending on the underlying transport protocol. (Available for TCP)

Method ManagesPackets : Bool () Property

This corresponds to the constructor argument of the same name. See also: New, Construct_Client

Method Ping : NetworkPing () Property

This specifies the last known ping of this client. This does not change while calculating a new ping.

Method PingTimer : TimePoint () Property

The last point in time used when pinging began. This property has protected assignment-access. See also: Pinging, Ping

Method Pinging : Bool () Property

This specifies if this client is currently calculating a ping. The Ping property is still valid while this is True. This property has protected assignment-access.


Method Documentation

Method AddWaitingMegaPacket : Void ( MP:MegaPacket )

This adds MP to an internal container for "waiting" (Remote) MegaPacket objects.

This method is protected, but is documented for extension purposes.

Method CalculatePing : Void ( Network:NetworkEngine, StopPinging:Bool=true )

This assigns this client's ping using ProjectedPing, resets the internal "ping timer", then resets the Pinging flag.

This method is protected, but is documented for extension purposes.

Method Close : Void ( Network:NetworkEngine, ReleaseInternalData:Bool=false )

This destructor is used internally. Please disconnect clients through their parent NetworkEngine objects. This will close a Socket if held by this object, invalidate the Address property, release any associated packet identifiers, release held MegaPacket handles, and set relevant closure-flags.

Method ConfirmPacket : Bool ( ID:PacketID )

This will confirm packets with ID as their identifier, but only if it hasn't already been identified. The return-value indicates if the operation failed.

Method Construct_Client : Client ( PacketConfirmation:Bool )

This is an internal constructor used when constructing Client objects.

  • The PacketConfirmation argument specifies if this Client will be keeping track of packet identifiers. (Non-reliable protocols)
This routine is protected, but documented for extension purposes.

Method ContainsPacket : Bool ( ID:PacketID )

This returns True if ID has already been confirmed. See also: ConfirmPacket, Update

Method GetWaitingMegaPacket : MegaPacket ( ID:PacketID )

This retrieves a "waiting" MegaPacket object with ID.

For details, view the AddWaitingMegaPacket method's documentation.

This method is protected, but is documented for extension purposes.

See also: AddWaitingMegaPacket, RemoveWaitingMegaPacket

Method HasWaitingMegaPacket : Bool ( ID:PacketID )

This states if a MegaPacket object with ID is inside this object's "waiting mega-packets" container.

This method is protected, but is documented for extension purposes.

See also: GetWaitingMegaPacket, AddWaitingMegaPacket, RemoveWaitingMegaPacket

Method ProjectedPing : NetworkPing ( Network:NetworkEngine )

This returns the "projected ping" of this client, based on the criteria specified in Network. "Projected pings" are approximate pings describing how long a client has been pinging. This number is not accurate unless the Pinging property reports True.

Method ReleaseNextPacketID : Void ()

This is an internal method that will automatically release the next packet identifier in the queue.

This method is protected, but is documented for extension purposes.

Method RemoveWaitingMegaPacket : Void ( MP:MegaPacket )

This is used to remove MP from an internal container of "waiting" (Client-created) MegaPackets.

This method is protected, but is documented for extension purposes.

See also: AddWaitingMegaPacket, AllocateRemoteMegaPacket

Method RemoveWaitingMegaPacket : Void ( ID:PacketID )

This removes a "waiting" MegaPacket with ID; calls the main implementation.

This method is protected, but is documented for extension purposes.

Method ResetPacketTimer : TimePoint ()

This resets the internal "packet timer", used for releasing reliable-packet identifiers.

This method is protected, but is documented for extension purposes.

Method ResetPingTimer : TimePoint ()

This resets an internal timer used for ping calculation.

This method is protected, but is documented for extension purposes.

Method Update : Void ( Network:NetworkEngine )

This is used to update a Client object. The main purpose of this is to handle reliable packet identifiers.

But this also handles ping calculation and MegaPacket handles.

See also: UpdateWaitingMegaPackets

Method UpdateWaitingMegaPackets : Void ( Network:NetworkEngine )

This updates any waiting MegaPacket handles; handles timeout semantics.

This is called internally by Update.

See also: Update