C# Class Protogame.MxDispatcher

The Mx dispatcher; this handles receiving messages on the UDP client and dispatching them to the correct connected Mx client.
Afficher le fichier Open project: RedpointGames/Protogame Class Usage Examples

Méthodes publiques

Méthode Description
Close ( ) : void

Closes the dispatcher permanently, terminating all inbound and outbound connections.

Connect ( IPEndPoint endpoint ) : MxClient

Explicitly connect to the specified endpoint, assuming there is an Mx dispatcher at the specified address.

This method is used to explicitly add clients, not to start the dispatcher. The dispatcher does not require an explicit start.

Disconnect ( MxClient client ) : void

Disconnects the specified Mx client. This removes it from the group that owns it, and prevents it from reconnecting to this dispatcher implicitly.

Disconnect ( MxClientGroup clientGroup ) : void

Disconnects the entire Mx client group, disconnecting all clients inside it.

GetBytesLastReceivedAndReset ( ) : int
GetBytesLastSentAndReset ( ) : int
MxDispatcher ( UdpClient client ) : System

Initializes a new instance of the MxDispatcher class.

MxDispatcher ( int port ) : System

Initializes a new instance of the MxDispatcher class.

PlaceInGroup ( MxClient client, string identifier ) : MxClientGroup

Places the specified Mx client in the specified group.

Send ( MxClient client, byte packet, bool reliable = false ) : void

Queue a packet for sending to the specified client.

Send ( MxClientGroup group, byte packet, bool reliable = false ) : void

Queue a packet for sending to the specified endpoint.

Update ( ) : void

Updates the dispatcher, receiving messages and connecting clients as appropriate.

this ( string identifier ) : MxClientGroup

Retrieves the client group for the given identifier.

Méthodes protégées

Méthode Description
OnClientConnected ( MxClient client ) : void

Raise the ClientConnected event.

OnClientDisconnectWarning ( Protogame.MxDisconnectEventArgs e ) : void

Raise the ClientDisconnectWarning event.

OnClientDisconnected ( MxClient client ) : void

Raise the ClientDisconnected event.

OnMessageAcknowledged ( Protogame.MxMessageEventArgs e ) : void

Raise the MessageAcknowledged event.

OnMessageLost ( Protogame.MxMessageEventArgs e ) : void

Raise the MessageLost event.

OnMessageReceived ( Protogame.MxMessageEventArgs e ) : void

Raise the MessageReceived event.

OnMessageSent ( Protogame.MxMessageEventArgs e ) : void

Raise the MessageSent event.

OnReliableReceivedProgress ( Protogame.MxReliabilityTransmitEventArgs e ) : void

Raise the ReliableReceivedProgress event.

OnReliableSendProgress ( Protogame.MxReliabilityTransmitEventArgs e ) : void

Raise the ReliableSendProgress event.

Private Methods

Méthode Description
AssertNotClosed ( ) : void

Assert that the dispatcher has not been closed.

OnClientDisconnectWarning ( object sender, Protogame.MxDisconnectEventArgs e ) : void

Handle receiving a DisconnectWarning event from a client.

OnClientMessageAcknowledged ( object sender, Protogame.MxMessageEventArgs e ) : void

Handle receiving a MessageAcknowledged event from a client.

OnClientMessageLost ( object sender, Protogame.MxMessageEventArgs e ) : void

Handle receiving a MessageLost event from a client.

OnClientMessageReceived ( object sender, Protogame.MxMessageEventArgs e ) : void

Handle receiving a MessageReceived event from a client.

OnClientMessageSent ( object sender, Protogame.MxMessageEventArgs e ) : void

Handle receiving a MessageSent event from a client.

OnReliabilityFragmentReceived ( object sender, Protogame.MxReliabilityTransmitEventArgs e ) : void

Handle receiving a FragmentReceived event from a reliability class.

OnReliabilityFragmentSent ( object sender, Protogame.MxReliabilityTransmitEventArgs e ) : void

Handle receiving a FragmentSent event from a reliability class.

OnReliabilityMessageAcknowledged ( object sender, Protogame.MxMessageEventArgs e ) : void

Handle receiving a MessageAcknowledged event from a reliability class.

OnReliabilityMessageReceived ( object sender, Protogame.MxMessageEventArgs e ) : void

Handle receiving a MessageReceived event from a reliability class.

ReceiveNonBlocking ( UdpClient client, IPEndPoint &receive ) : byte[]

Receive a message in an non-blocking manner. If there is no message to receive, this function returns null.

RegisterForEvents ( MxClient client ) : void

Register for a client's events.

RegisterForEvents ( MxReliability reliability ) : void

Register for a reliability's events.

ThreadSafeGetOrCreateClient ( IPEndPoint endpoint ) : MxClient
UnregisterFromEvents ( MxClient client ) : void

Unregister from a client's events.

UnregisterFromEvents ( MxReliability reliability ) : void

Unregister from a reliability's events.

Method Details

Close() public méthode

Closes the dispatcher permanently, terminating all inbound and outbound connections.
public Close ( ) : void
Résultat void

Connect() public méthode

Explicitly connect to the specified endpoint, assuming there is an Mx dispatcher at the specified address.

This method is used to explicitly add clients, not to start the dispatcher. The dispatcher does not require an explicit start.

public Connect ( IPEndPoint endpoint ) : MxClient
endpoint System.Net.IPEndPoint /// The endpoint to connect to. ///
Résultat MxClient

Disconnect() public méthode

Disconnects the specified Mx client. This removes it from the group that owns it, and prevents it from reconnecting to this dispatcher implicitly.
public Disconnect ( MxClient client ) : void
client MxClient The client.
Résultat void

Disconnect() public méthode

Disconnects the entire Mx client group, disconnecting all clients inside it.
public Disconnect ( MxClientGroup clientGroup ) : void
clientGroup MxClientGroup The client group.
Résultat void

GetBytesLastReceivedAndReset() public méthode

public GetBytesLastReceivedAndReset ( ) : int
Résultat int

GetBytesLastSentAndReset() public méthode

public GetBytesLastSentAndReset ( ) : int
Résultat int

MxDispatcher() public méthode

Initializes a new instance of the MxDispatcher class.
public MxDispatcher ( UdpClient client ) : System
client System.Net.Sockets.UdpClient
Résultat System

MxDispatcher() public méthode

Initializes a new instance of the MxDispatcher class.
public MxDispatcher ( int port ) : System
port int /// The port of the UDP client. ///
Résultat System

OnClientConnected() protected méthode

Raise the ClientConnected event.
protected OnClientConnected ( MxClient client ) : void
client MxClient /// The client. ///
Résultat void

OnClientDisconnectWarning() protected méthode

Raise the ClientDisconnectWarning event.
protected OnClientDisconnectWarning ( Protogame.MxDisconnectEventArgs e ) : void
e Protogame.MxDisconnectEventArgs /// The event arguments. ///
Résultat void

OnClientDisconnected() protected méthode

Raise the ClientDisconnected event.
protected OnClientDisconnected ( MxClient client ) : void
client MxClient /// The client. ///
Résultat void

OnMessageAcknowledged() protected méthode

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

OnMessageLost() protected méthode

Raise the MessageLost event.
protected OnMessageLost ( Protogame.MxMessageEventArgs e ) : void
e Protogame.MxMessageEventArgs /// The event arguments. ///
Résultat void

OnMessageReceived() protected méthode

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

OnMessageSent() protected méthode

Raise the MessageSent event.
protected OnMessageSent ( Protogame.MxMessageEventArgs e ) : void
e Protogame.MxMessageEventArgs /// The event arguments. ///
Résultat void

OnReliableReceivedProgress() protected méthode

Raise the ReliableReceivedProgress event.
protected OnReliableReceivedProgress ( Protogame.MxReliabilityTransmitEventArgs e ) : void
e Protogame.MxReliabilityTransmitEventArgs /// The event arguments. ///
Résultat void

OnReliableSendProgress() protected méthode

Raise the ReliableSendProgress event.
protected OnReliableSendProgress ( Protogame.MxReliabilityTransmitEventArgs e ) : void
e Protogame.MxReliabilityTransmitEventArgs /// The event arguments. ///
Résultat void

PlaceInGroup() public méthode

Places the specified Mx client in the specified group.
public PlaceInGroup ( MxClient client, string identifier ) : MxClientGroup
client MxClient The Mx client.
identifier string The group identifier.
Résultat MxClientGroup

Send() public méthode

Queue a packet for sending to the specified client.
public Send ( MxClient client, byte packet, bool reliable = false ) : void
client MxClient /// The client to send the message to. ///
packet byte /// The associated data to send. ///
reliable bool /// Whether or not this message should be sent reliably and intact. This also /// permits messages larger than 512 bytes to be sent. ///
Résultat void

Send() public méthode

Queue a packet for sending to the specified endpoint.
public Send ( MxClientGroup group, byte packet, bool reliable = false ) : void
group MxClientGroup /// The group to send the message to. ///
packet byte /// The associated data to send. ///
reliable bool /// Whether or not this message should be sent reliably and intact. This also /// permits messages larger than 512 bytes to be sent. ///
Résultat void

Update() public méthode

Updates the dispatcher, receiving messages and connecting clients as appropriate.
public Update ( ) : void
Résultat void

this() public méthode

Retrieves the client group for the given identifier.
public this ( string identifier ) : MxClientGroup
identifier string The identifier for the group.
Résultat MxClientGroup