Skip to content

MajorTomAW/EnhancedOnlineSessions

Repository files navigation

Enhanced Online Sessions Plugin

An Unreal Engine Plugin used to manage an online subsystem
Developed in Unreal Engine 5.3. Works on any Unreal Engine 5 Version.

Tired of the Advanced Sessions Plugin?
This is the new one!
Much more modular and should work right out of the box.

EnhancedOnlineSessions Subsystem that helps communicating with the online service.
Supports STEAM, Epic Online Services (EOS) and EOS Plus.
Including platform specific settings which can be changed inside the Editor.

Well my goal was to make this plugin as modular as possible that it works with any other project.
The entire online service logic is stored into a custom UGameInstanceSubsystem.

๐Ÿ’ก Suggestions or Feedback is much appreciated: My Discord Account. Feel free to DM me any time! ๐Ÿ™‚

Documentation

  1. Setup
    ย 1.1 Configure your Project using the Online Subsystem of your Choice
    ย 1.2 Structure of the Enhanced Sessions
    ย 1.3 Session Maps
  2. Sessions
    2.1 Host Online Sessions
    ย ย ย ย ย 2.1.1 Host Session
    ย ย ย ย ย 2.1.2 Host Peer 2 Peer Lobby
    2.2 Start Session
    2.3 Find Sessions
    ย ย ย ย ย 2.3.1 Get Current Players
    ย ย ย ย ย 2.3.1 Get Max Players
    ย ย ย ย ย 2.3.1 Get Session Friendly Name
    ย ย ย ย ย 2.3.1 Get Ping in Ms
  3. Identity
    ย 3.1 Login User
    ย 3.2 Kick Player
    ย 3.2 Ban Player
    ย 3.2 Change Player Name
  4. Friends
    ย 3.2 Coming Soon...

1.1 Configure your Project

In Project Settings > Plugins there is a section called Online Enhanced Subsystem.

image

Here you can select the Online Subsystem of your Choice and configure its parameters.
This will write the changes directly into the DefaultEngine.ini so you wont have to do that manually anymore :)

๐Ÿ“You will be prompted to restart the Editor after.

1.2 Structure of the Enhanced Sessions

๐Ÿ’กThe Enhanced Sessions Subsystem follows a consistent structure.
All the necessary functions are stored inside the EnhancedOnlineSubsystem

image

These function will always take in a request object, which defines the action that you want to perform.
Every request will have multiple callbacks, that you can bind functions to (Based on the request type).
However, every request will have an OnFailedDelegate which will be called if the request fails and the log why the request may have failed will be passed through.

1.3 Session Maps with the Asset manager

If you want to use a Level for an Online Session you would need to tell the Asset Manager about its existence.
To do that you would need to go inside your Project Settings -> Asset Manager

Screenshot 2024-05-10 022213

And then make sure to uncheck Is Editor Only and add the Directory where your Level is located.

Screenshot 2024-05-10 022219

2.1 Online Sessions

An online session is basically an instance of the game running on the server with a given set of properties which is either advertised so that it can be found and joined by players wanting to play the game or private so only players who are invited or notified of it in some way can join.

The basic lifetime of a sessions is:

  • Host a new session with desired settings.
  • Wait for players to request to join the session.
  • Register players who want to join.
  • Start the session.
  • Play the match.
  • End Session or destroy the session.

To Host an Online Session you need to call the HostOnlineSession function which you can find in the EnhancedOnlineSubsystem.

image

This takes in a HostSessionRequest.
There are two different types of sessions you can host:

2.1.1 Host Session

To host a Session you need to construct an Online Host Session Request.
Note that this will automatically travel to the map you selected in Map Id.

๐Ÿ’ก If you are not able to find your Map in Map Id checkout Session Maps and make sure you have setup everything correctly.

image

Parameter Description
Online Mode: Defines the online mode of the session. You can choose from: Offline / Online / LAN. The Online Mode: "Online" adds ?listen to the travel url so you would not need to add that manually to the Travel URL Operators
Max Player Count The maximum number of players that can be in the Session.
Map Id Primary Asset Structure of the map you want to travel to, when the Session gets created.
Travel URL Operators Adds additional operators that will be apended to the Travel URL.
Friendly Name The friendly name of the session that will be used to display the Session name in the UI.
Search Keyword The searchkeyword can be used for different scenarios. If you use EOS you will notice that this is the official SEARCH_KEYWORD combined with the Session. However you can also use it with any other online subsystem to filter your Session Results, depending on what Sessions you want to find
Use Lobbies if Available Sets if the session should use player hosted Lobbies.
Use Voice Chat if Available Some online services provide Voice Chat. This Settings defines if we use the Voice Chat.
Game Mode Advertisement Name The advertisement name of the game mode that your session currently has. Can be used to advertise your session like Team Deathmatch, etc.
Is Presence Defines if the hosted session should use Presence (Account Services)
Allow Join in Progress Sets if other players can join the session when the session already is in progress. This can be used to disable joining when your game has been started.
On Failed Delegate Delegate that will be called when the request failed for some reason.

2.1.2 Host Peer 2 Peer Lobby

To host a Peer 2 Peer Lobby you need to construct a Host P2P Lobby Request.

๐Ÿ’กNote that this will NOT travel to a different map, as the P2P Lobby stays in the current level and you need to server travel manually.

image

Very similar to Host Online Session, this takes in a few parameters:

Parameter Description
Online Mode Defines the online mode of the session. You can choose from: Offline / Online / LAN.
Max Player Count The maximum number of players that can be in the Session.
Friendly Name The friendly name of the session that will be used to display the Session name in the UI.
Search Keyword The searchkeyword can be used for different scenarios. If you use EOS you will notice that this is the official SEARCH_KEYWORD combined with the Session. However you can also use it with any other online subsystem to filter your Session Results, depending on what Sessions you want to find
Use Voice Chat if Available Some online services provide Voice Chat. This Settings defines if we use the Voice Chat.
Game Mode Advertisement Name The advertisement name of the game mode that your session currently has. Can be used to advertise your session like Team Deathmatch, etc.
Is Presence Defines if the hosted session should use Presence (Account Services)
Allow Join in Progress Sets if other players can join the session when the session already is in progress. This can be used to disable joining when your game has been started.
On Succeeded Delegate This Delegate will be called whenever the lobby creation was a success.
On Failed Delegate Delegate that will be called when the request failed for some reason.

Rest of the documenation is currently in progress...

2.2 Start Session

Starting a session basically sets its current state to InProgress meaning the the session is now registered as in progress in the online subsystem you are using. This also blocks other players from joining if you disabled the option Allow Join in Progress in Host Online Sessions.

To start the session you would need to call the Start Online Session function which you can find in the Enhanced Online Subsystem

image

This takes in a Start Session Request.

image

Parameter Description
On Succeeded Delegate Delegate that will be called when the Start Session Request succeeded and the current session is now set to be in progress.
On Failed Delegate Delegate that will be called when the request failed for some reason.

As you can see this request does not take in any additional inputs, since you are only able to start the current session you are in.
You could use the On Succeeded Delegate to start the match and a timer for example.

๐Ÿ“ You dont have to start a session to start the match. Starting a session is more like a helper which the engine provides to help you doing the session management. Meaning that your game would still work fine if you dont start your session.

2.3 Find Sessions

The most basic form of searching for sessions is the classic server browser that shows all available games and allows the player to filter those based on the type of game they want to play and then choose one to join one of the sessions that match those criteria.
To find these sessions you would need to call the Find Online Sessions function which you can find in the Enhanced Online Subsystem.

image

This takes in a Find Sessions Request.

image

Parameter Description
Online Mode Defines the online mode of the session you want to filter for. You can choose from: Offline / Online / LAN.
Max Search Results The maximum number of sessions which can be found by the player requesting the find sessions.
Find Lobbies Whether we want to find player hosted lobbies.
Search Keyword Takes in an optional keyword if you want to filter the sessions you want to find. This Keyword can be assigned to a session in Host Online Sessions.
On Succeeded Delegate Delegate that will be called when the Find Sessions Request succeeded and we have a list of found sessions.
On Failed Delegate Delegate that will be called when the request failed for some reason.

2.3.1 Get Current Players

Returns the number of current players which are inside the session search result.
image

Parameter Description
Search Result The session search result you want to read the current players from.

2.3.2 Get Max Players

Returns the maximum amount of players which could be possibly inside the session search result.

image

Parameter Description
Search Result The session search result you want to read the maxplayers from.

2.3.3 Get Session Friendly Name

Returns the friendly name of the session search result. The friendly name can be assigned to a session in Host Online Sessions.

image

Parameter Description
Search Result The session search result you want to read the friendly name from.

2.3.4 Get Ping in Ms

Pings the session search result and returns the ping duration in ms.

๐Ÿ“ Some online subsystems do not support that action or require further work to make this working.

image

Parameter Description
Search Result The session search result you want to ping.