Search Results for

    Show / Hide Table of Contents

    Class BaseNetworkRoom

    This class represents the network room.

    Inheritance
    object
    BaseNetworkRoom
    LocalNetworkRoom
    Implements
    INetworkRoom
    IRoomInfo
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Evergine.Networking.Rooms
    Assembly: Evergine.Networking.dll
    Syntax
    public abstract class BaseNetworkRoom : INetworkRoom, IRoomInfo

    Constructors

    BaseNetworkRoom()

    Initializes a new instance of the BaseNetworkRoom class.

    Declaration
    protected BaseNetworkRoom()

    BaseNetworkRoom(RoomOptions)

    Initializes a new instance of the BaseNetworkRoom class.

    Declaration
    protected BaseNetworkRoom(RoomOptions options)
    Parameters
    Type Name Description
    RoomOptions options

    The room options for the new room.

    Fields

    FirstPlayerId

    Constant that defines the player id that will be assigned to the first player that enters the room.

    Declaration
    protected const int FirstPlayerId = 0
    Field Value
    Type Description
    int

    internalRoomInfo

    Internal room info.

    Declaration
    protected RoomInfo internalRoomInfo
    Field Value
    Type Description
    RoomInfo

    Properties

    AllPlayers

    Gets the "list" of all the players who are in that room (including the local player). Only updated while inside a Room.

    Declaration
    public IEnumerable<INetworkPlayer> AllPlayers { get; }
    Property Value
    Type Description
    IEnumerable<INetworkPlayer>

    CustomProperties

    Gets the custom properties of the room. Those properties are synchronized by the server automatically.

    Declaration
    public NetworkPropertiesTable CustomProperties { get; }
    Property Value
    Type Description
    NetworkPropertiesTable
    Remarks

    All players inside the room can change these properties. Setting properties in this table updates the server and other players.

    Keys in the table are bytes to reduce network traffic. It is recommended to use a custom enumerator for better clarity.

    Examples
      var matchmakingClient = Evergine.GetService<MatchmakingClientService>();
                            var roomProperties = matchmakingClient.CurrentRoom.CustomProperties;
                            roomProperties.Set((byte)CustomEnum.MapLevel, "cs_italy");
                            var mapLevel = roomProperties.GetString((byte)CustomEnum.MapLevel);
    

    IsFull

    Gets a value indicating whether the room is full and therefore, no more players can join it.

    Declaration
    public bool IsFull { get; }
    Property Value
    Type Description
    bool

    IsVisible

    Gets a value indicating whether the room is listed in its lobby.

    Declaration
    public virtual bool IsVisible { get; set; }
    Property Value
    Type Description
    bool
    Remarks

    Rooms can be created invisible, or changed to invisible.

    MasterClientId

    Gets the Id of the player who's the master of this Room. Note: This changes when the current master leaves the room.

    Declaration
    public int MasterClientId { get; protected set; }
    Property Value
    Type Description
    int

    MaxPlayers

    Gets the limit of players for this room. This property is shown in lobby, too. If the room is full (players count == maxplayers), joining this room will fail.

    Declaration
    public virtual byte MaxPlayers { get; set; }
    Property Value
    Type Description
    byte
    Remarks

    If the player has joined the room, the setter will update the server and all clients.

    Name

    Gets the name of a room. Unique identifier for a room/match (per AppId + game-Version).

    Declaration
    public string Name { get; }
    Property Value
    Type Description
    string
    Remarks

    The name can't be changed once it's set by the matchmaking server.

    PlayerCount

    Gets the count of players currently in room.

    Declaration
    public byte PlayerCount { get; }
    Property Value
    Type Description
    byte

    PropertiesListedInLobby

    Gets a set of string properties that are in the RoomInfo of the Lobby. This list is defined when creating the room and can't be changed afterwards.

    Declaration
    public HashSet<string> PropertiesListedInLobby { get; }
    Property Value
    Type Description
    HashSet<string>
    Remarks

    You could name properties that are not set from the beginning. Those will be synchronized with the lobby when added later on.

    Methods

    GetPlayer(int)

    Tries to find the player with given player id. Only useful when in a Room, as Ids are only valid per Room.

    Declaration
    public INetworkPlayer GetPlayer(int playerId)
    Parameters
    Type Name Description
    int playerId

    Player id of a player in this room.

    Returns
    Type Description
    INetworkPlayer

    Player or null.

    InternalAddPlayer(BaseNetworkPlayer)

    Internal method to add a player in the players list.

    Declaration
    protected void InternalAddPlayer(BaseNetworkPlayer player)
    Parameters
    Type Name Description
    BaseNetworkPlayer player

    The player to add.

    InternalAddPlayer(BaseNetworkPlayer, int)

    Internal method to add a player in the players list.

    Declaration
    protected void InternalAddPlayer(BaseNetworkPlayer player, int playerId)
    Parameters
    Type Name Description
    BaseNetworkPlayer player

    The player to add.

    int playerId

    The assigned player id.

    InternalRemovePlayer(int)

    Internal method to remove a player from the players list.

    Declaration
    protected void InternalRemovePlayer(int playerId)
    Parameters
    Type Name Description
    int playerId

    The player id of the player to remove.

    OnChange(RoomFieldsFlags)

    Called when one or more properties are refreshed.

    Declaration
    protected virtual void OnChange(BaseNetworkRoom.RoomFieldsFlags changedFields)
    Parameters
    Type Name Description
    BaseNetworkRoom.RoomFieldsFlags changedFields

    Flag indicating what fields have been changed.

    WriteToMessage(OutgoingMessage, RoomFieldsFlags)

    Writes the specified fields to an outgoing message.

    Declaration
    protected void WriteToMessage(OutgoingMessage message, BaseNetworkRoom.RoomFieldsFlags includedFields)
    Parameters
    Type Name Description
    OutgoingMessage message

    The outgoing message.

    BaseNetworkRoom.RoomFieldsFlags includedFields

    Indicates the fields that must synchronized.

    Events

    MasterClientIdChanged

    Occurs when the master client id changes

    Declaration
    public event EventHandler MasterClientIdChanged
    Event Type
    Type Description
    EventHandler

    Implements

    INetworkRoom
    IRoomInfo

    Extension Methods

    ReflectionHelper.GetMemberAssembly(object)
    ReflectionHelper.GetTypeName(object)
    In This Article
    Back to top
    Generated by DocFX