C# Class Protogame.MxReliability

The class that provides reliability and fragmentation infrastructure for Mx clients.

This class is used by MxDispatcher to interface with an MxClient in a reliable manner. When data is sent reliably, this class is used to fragment and reconstruct sets of data, ensuring that each fragment is either acknowledged by the receiving machine, or sent again.

Show file Open project: RedpointGames/Protogame Class Usage Examples

Public Methods

Method Description
MxReliability ( MxClient client ) : System

Initializes a new instance of the MxReliability class.

Send ( byte data ) : void

Sends data to the associated client reliably.

Update ( ) : void

Updates this reliability class, sending and receiving messages as required.

Protected Methods

Method Description
OnFragmentReceived ( Protogame.MxReliabilityTransmitEventArgs e ) : void

Raise the FragmentReceived event.

OnFragmentSent ( Protogame.MxReliabilityTransmitEventArgs e ) : void

Raise the OnFragmentSent event.

OnMessageAcknowledged ( Protogame.MxMessageEventArgs e ) : void

Raise the MessageAcknowledged event.

OnMessageReceived ( Protogame.MxMessageEventArgs e ) : void

Raise the MessageReceived event.

Private Methods

Method Description
CheckForFullAcknowledgement ( ) : void

Checks for and finishes any active messages that have now been completely acknowledged by the receiver.

ClientOnMessageAcknowledged ( object sender, Protogame.MxMessageEventArgs mxMessageEventArgs ) : void

Called when one of the fragments has been acknowledged by the remote client.

ClientOnMessageLost ( object sender, Protogame.MxMessageEventArgs mxMessageEventArgs ) : void

Called when one of the fragments has been detected as lost.

ClientOnMessageReceived ( object sender, Protogame.MxMessageReceiveEventArgs mxMessageEventArgs ) : void

Called when we have received a fragment from the underlying client.

UpdateReceive ( ) : void

Handles receiving fragments and firing the MessageReceived event when reconstruction is complete.

UpdateSend ( ) : void

Handles sending out fragments based on the messages in the queue.

UpdateSendActiveMessages ( ) : bool

Attempt to queue packets for the current active messages that need sending and returns whether it queued anything. If it didn't, then we return false and the caller (UpdateSend) can pick up another active message.

Method Details

MxReliability() public method

Initializes a new instance of the MxReliability class.
public MxReliability ( MxClient client ) : System
client MxClient /// The client that this reliability class is associated with. ///
return System

OnFragmentReceived() protected method

Raise the FragmentReceived event.
protected OnFragmentReceived ( Protogame.MxReliabilityTransmitEventArgs e ) : void
e Protogame.MxReliabilityTransmitEventArgs /// The event arguments. ///
return void

OnFragmentSent() protected method

Raise the OnFragmentSent event.
protected OnFragmentSent ( Protogame.MxReliabilityTransmitEventArgs e ) : void
e Protogame.MxReliabilityTransmitEventArgs /// The event arguments. ///
return void

OnMessageAcknowledged() protected method

Raise the MessageAcknowledged event.
protected OnMessageAcknowledged ( Protogame.MxMessageEventArgs e ) : void
e Protogame.MxMessageEventArgs /// The event arguments. ///
return void

OnMessageReceived() protected method

Raise the MessageReceived event.
protected OnMessageReceived ( Protogame.MxMessageEventArgs e ) : void
e Protogame.MxMessageEventArgs /// The event arguments. ///
return void

Send() public method

Sends data to the associated client reliably.
public Send ( byte data ) : void
data byte /// The data to be sent. ///
return void

Update() public method

Updates this reliability class, sending and receiving messages as required.
public Update ( ) : void
return void