Room Server Connection¶
Room servers are the workhorses of Strix. They contain the information of the different rooms and the player lists inside them. Room Servers also control and Relay messages and events between the players in the room. A connection to a room server must be established in order to join rooms.
You can connect to a room server explicitly as explained on this page, or you can do so implicitly by calling functions that automatically connects to a room server as needed.
Node Room¶
A Node in the Strix Unreal SDK terminology refers to a room server. A room server can contain many rooms, and there may be multiple room servers in your server system (a server cluster). To access to a particular room, the SDK needs to know a pair of identities; one for a room server and another for a room in it.
Strix Unreal SDK sometimes refers to the pair as NodeRoom. A NodeRoom is the combination of a Room Server and a room, representing a specific room alongside its Room Server’s information. Many functions that handle NodeRoom automatically connect to an appropriate room server. This simplifies operations on rooms, without having to first connect to a specific Room Server.
Searching for a Room Server¶
To connect to a Room Server explicitly, you need to know available room servers. The Master Server of your cluster contains the information of its connected room servers. The Strix Unreal SDK provides functions for querying this information.
The SearchNode function searches for running room servers that match a given condition. The SearchNodeRoom function searches for any rooms matching a given condition and returns information of both Rooms and Room Servers.
Note
SearchNode returns a list of Room Servers that matches the conditions. The Master Server, however, may add some implicit conditions to the client-supplied conditions to further filter the list. If you are using Strix Cloud and your servers are version 1.2.0 or later, Master Servers implicitly filter out Room Servers that are already full in the number of rooms, i.e., Master Servers won’t return a Room Server the number of whose rooms already reached its Max Room Count config value.
Connecting to a Room Server¶
A connection to a Room Server can be made through the use of several different functions. The most obvious is the ConnectToRoomServer function which connects to a Room Server specified by a host name, port, and protocol, which you can obtain through the results of the SearchNode or SearchNodeRoom function.
The functions JoinNodeRoom, JoinRandomNodeRoom, and CreateNodeRoom all join the client to a room, and, in the process, they also connect to the room’s Room Server. JoinNodeRoom requires a Strix Node Room Info struct that contains a Room Server info., so a Room Server be found beforehand. All of these three functions require a Master Server connection while no Room Server connection is required.
To facilitate connections to multiple Room Servers or rooms, connecting to a Room Server requires a channel argument, which specifies the ID for the connection. The channel ID is mapped to this specific connection and can be referred to by components and other functions in their channel ID arguments to operate on the connection (see Multiple Rooms and Channels).
Note
The SDK limits each channel to having only one Room Server connection with one possible room. It is allowed to connect to a same room server through two or more channels.
Note
The ConnectToRoomServer function requires protocol parameter. You should pass a value taken from Strix Node struct.
If you are using Strix Cloud, the protocol to connect to a room server is always “TCP”.
Disconnection¶
The DisconnectRoomServer function will disconnect the client from a Room Server. This will prevent further synchronization and will result in the client being disconnected from the room on that channel.
Status¶
You can check if a Room Server is connected using the IsRoomServerConnected function, with the channel ID of the connection you wish to check.
Timeout¶
Room Server connections will timeout after no activity for some time. Unlike a Master Server connection, a Room Server timeout is a hard loss of connection and will result in the player leaving a room on that channel if they are in one. This will require a reconnection to the Room Server.
To prevent such a loss, Strix Unreal SDK automatically sends heartbeat messages to a room server periodically. The default configuration is that the heartbeat period is 10 seconds and the server’s timeout is 120 seconds, so the room server connection would not timeout under a normal course of operation.
Note
The heartbeat timeout can be configured on the server-side, and you can also change the heartbeat period using the SDK (See Server-synchronized time for details). Please be careful when you change these values because inappropriate settings could lead to unintentional room server disconnection.