Class MatchmakingServerService
The server service for matchmaking.
Inheritance
Implements
Inherited Members
Namespace: Evergine.Networking.Server
Assembly: Evergine.Networking.dll
Syntax
public class MatchmakingServerService : UpdatableService, IDependencyObject
Constructors
MatchmakingServerService()
Initializes a new instance of the MatchmakingServerService class.
Declaration
public MatchmakingServerService()
Properties
AllConnectedPlayers
Gets all the players connected to the matchmaking service.
Declaration
public IEnumerable<ServerPlayer> AllConnectedPlayers { get; }
Property Value
Type | Description |
---|---|
IEnumerable<ServerPlayer> |
AllRooms
Gets all the players that are in the lobby.
Declaration
public IEnumerable<ServerRoom> AllRooms { get; }
Property Value
Type | Description |
---|---|
IEnumerable<ServerRoom> |
ApplicationIdentifier
Gets or sets the application Identifier. Used by the matchmaking server to separate players by different game.
Declaration
public string ApplicationIdentifier { get; set; }
Property Value
Type | Description |
---|---|
string |
ClientApplicationVersion
Gets or sets the version of your client. A new version also creates a new "virtual app" to separate players from older client versions.
Declaration
public string ClientApplicationVersion { get; set; }
Property Value
Type | Description |
---|---|
string |
ConnectionTimeout
Gets or sets the connection timeout. Default value is 25 seconds.
Declaration
public TimeSpan ConnectionTimeout { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
NetworkFactory
Gets or sets the factory used to create the INetworkServer peer.
Declaration
public INetworkFactory NetworkFactory { get; set; }
Property Value
Type | Description |
---|---|
INetworkFactory |
PingInterval
Gets or sets the ping interval. Default value is 4 seconds.
Declaration
public TimeSpan PingInterval { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
PlayersInLobby
Gets all the players that are in the lobby.
Declaration
public IEnumerable<ServerPlayer> PlayersInLobby { get; }
Property Value
Type | Description |
---|---|
IEnumerable<ServerPlayer> |
ServerName
Gets or sets the server name. It is sent in every discovery response.
Declaration
public string ServerName { get; set; }
Property Value
Type | Description |
---|---|
string |
Methods
CreateMessage()
Creates a new outgoing message.
Declaration
public OutgoingMessage CreateMessage()
Returns
Type | Description |
---|---|
OutgoingMessage | The create outgoing message. |
FindPlayer(NetworkEndpoint)
Looks for a player with the specified endpoint.
Declaration
public ServerPlayer FindPlayer(NetworkEndpoint playerEndpoint)
Parameters
Type | Name | Description |
---|---|---|
NetworkEndpoint | playerEndpoint | The player endpoint. |
Returns
Type | Description |
---|---|
ServerPlayer | The ServerPlayer if the player can be found; otherwise, null. |
SendToClient(OutgoingMessage, NetworkEndpoint, DeliveryMethod)
Sends a user data message to the matchmaking server.
Declaration
public void SendToClient(OutgoingMessage messageToSend, NetworkEndpoint destinationClient, DeliveryMethod deliveryMethod)
Parameters
Type | Name | Description |
---|---|---|
OutgoingMessage | messageToSend | The message to be sent. |
NetworkEndpoint | destinationClient | The destination client endpoint. |
DeliveryMethod | deliveryMethod | The delivery method. |
ShutdownAsync()
Shutdowns the matchmaking server on the specified port.
Declaration
public Task ShutdownAsync()
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
StartAsync(int)
Starts the matchmaking server on the specified port.
Declaration
public Task StartAsync(int port)
Parameters
Type | Name | Description |
---|---|---|
int | port | The port to bind to. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Application identifier parameter can't be null or empty. |
InvalidOperationException | ApplicationIdentifier must have a valid value before initialize. or You can't call multiple times to Start method. |
Update(TimeSpan)
Updates this instance.
Declaration
public override void Update(TimeSpan gameTime)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | gameTime | The elapsed game time since the last update. |
Overrides
Events
MessageReceivedFromClient
Occurs when a user data message from a client is received by the host
Declaration
public event EventHandler<MessageReceivedEventArgs> MessageReceivedFromClient
Event Type
Type | Description |
---|---|
EventHandler<MessageReceivedEventArgs> |
PlayerConnected
Occurs when a new player connects with the server
Declaration
public event EventHandler<ServerPlayer> PlayerConnected
Event Type
Type | Description |
---|---|
EventHandler<ServerPlayer> |
PlayerDisconnected
Occurs when a player disconnects from the server
Declaration
public event EventHandler<ServerPlayer> PlayerDisconnected
Event Type
Type | Description |
---|---|
EventHandler<ServerPlayer> |
PlayerJoined
Occurs when a connected player joins in an existing room
Declaration
public event EventHandler<ServerPlayer> PlayerJoined
Event Type
Type | Description |
---|---|
EventHandler<ServerPlayer> |
PlayerJoining
Occurs when a connected player is joining to an existing room. This event is not fired when the first player creates the room.
Declaration
public event EventHandler<PlayerJoiningEventArgs> PlayerJoining
Event Type
Type | Description |
---|---|
EventHandler<PlayerJoiningEventArgs> |
PlayerLeaving
Occurs when a connected player is leaving an existing room
Declaration
public event EventHandler<ServerPlayer> PlayerLeaving
Event Type
Type | Description |
---|---|
EventHandler<ServerPlayer> |
PlayerLeft
Occurs when a connected player left an existing room
Declaration
public event EventHandler<ServerPlayer> PlayerLeft
Event Type
Type | Description |
---|---|
EventHandler<ServerPlayer> |
PlayerSynchronized
Occurs when the server receives changes of the properties of a player
Declaration
public event EventHandler<ServerPlayer> PlayerSynchronized
Event Type
Type | Description |
---|---|
EventHandler<ServerPlayer> |
RoomCreated
Occurs when the server creates a new room in the lobby
Declaration
public event EventHandler<ServerRoom> RoomCreated
Event Type
Type | Description |
---|---|
EventHandler<ServerRoom> |
RoomDestroyed
Occurs when the server destroys an existing room in the lobby
Declaration
public event EventHandler<ServerRoom> RoomDestroyed
Event Type
Type | Description |
---|---|
EventHandler<ServerRoom> |
RoomSynchronized
Occurs when the server receives changes of the properties of a room
Declaration
public event EventHandler<ServerRoom> RoomSynchronized
Event Type
Type | Description |
---|---|
EventHandler<ServerRoom> |