Advice moving forward with Steam?

Hello am currently trying to setup Steam with my project.
I got the overlay working, that was the easy part, thank you .

But am very unsure where to go from , i tried finding a local server in Steam but had no luck of yet.
I have not done anything with the API other then the following Wiki.

Now am guessing i need to initialize it some where?
Seeing that i have not called ::SteamAPI_Init() anywhere.

I was hoping someone can give me some advice on where to do this?
I am looking at several classes AGameMode::, UGameInstance::.
But before i start typing code i like to make sure am implementing it the preferred way.

Thanks for any advice.

There’s little information on how people are using Steam (I guess because most people (indie devs?) don’t have access to SteamWorks yet?)
I would really appreciate if you could share your findings! :smiley:

I believe if you have all the correct config/build.cs settings for Steam setup, then the Engine itself will call the SteamAPI setup functions (See OnlineSubsystemSteam.cpp). I’m not sure whether it is possible to correctly use the Steam online services fully with the test App ID that is currently being used. We found a lot of the interfaces were built with the PC and steam in mind, so any calls for online systems and interfaces should work with Steam without much need for tweaking.

Hello and thank you for the replys.

@Zoc: I will be updating my progress and when done, i will be posting a Wiki on it as well.

@Dune: I belive that i have everything setup correctly, and it do seem like its beeing initialized by the engine.

Now after first testing the map with no Steamworks added to the project i get my dedicated server running and clients can join and level tiles are beeing streamed in.
How ever when i add the support for Steam i am unable to connect that is to say, client ends up alone, am guessing this is due to the fact that it now want me to join thru steam.

And not the shortcut target commands e.g:
Client: [FONT=Century Gothic]“C:\Program Files\Epic Games\4.8\Engine\Binaries\Win64\UE4Editor.exe” “C:\GameDev\MyGameTrunk\MyGame.uproject” -game 127.0.0.1 -log
Dedicated Server: [FONT=Century Gothic]“C:\Program Files\Epic Games\4.8\Engine\Binaries\Win64\UE4Editor.exe” “C:\GameDev\MyGameTrunk\MyGame.uproject” -server -game -log

I will update again when i have some more info on the subject.
Advice is stile very much aprichiated.

Edit: Just so its mentioned i did not download any SDK for steam as.
All files seem available allready in the engine directory.

Oh gee I should really take some time to write a basic Tutorial.

The way it works is basically, all Steam-relevant stuff is hidden behind the Online Subsystem Interface. (see https://docs.unrealengine.com/latest/INT/API/Runtime/OnlineSubsystem/index.html).
It’s rightly hidden behind this to help Multiplatform developping. It helps to be Agnostic to the online session sothat you can basically write the same lines of codes for Steam, PSN or XBox Live.
If you have the overlay working, calling the IOnlineSubsystem::Get() Function should retrieve you the FOnlineSubsystemSteam Implementation hidden behind the interface. (https://docs.unrealengine.com/latest/INT/API/Runtime/OnlineSubsystemSteam/FOnlineSubsystemSteam/index.html)

From there, there are multiple sub-interfaces that you can call. If available, you may use functions on them that will directly work with the Steam API.
Now, you may have some problems with those as the documentation is basically non-existent. I had to read the source code to understand what’s going on behind it and some functions are basically not working. (for instance, there is simply no implementation for Steam behind IOnlineFriends::SendInvite, you have to use IOnlineSession::SendSessionInviteToFriend. And the code is full of these kind of stupid stuff. Sometimes, you won’t set the right bool, or won’t use this and this correctly and it will take a lot of patience and step by step debugging to figure out what’s going on.

The way I’ve seen it made by Unreal Developpers is basically extending GameSession and using an extended GameInstance to call the GameSessions.Within the GameSession you can use the IOnlineSession for instance to find servers, advertise a created Server, etc. It’s important to recognize that most of the IOnlineInterfaces functions are using asynchronous requests and are basically in the form of “RequestSomething” - “OnRequestedSomethingEnded” format. So you better know exactly how delegates work in Unreal Engine (and it’s unfortunately a bit clunky as well).

All in all, there’s a lot of built-in stuff. Hell, I’ve been working on those for three months full-time and I still don’t know everything in it. I wish there was better documentation, high level architecture stuff would definitely help - I can figure out the specifics. It’s not that hard to get basic stuff working once you understand how all of it works. I’ve been planning to do a full tutorial on it when I’ll have some spare time but that may be in months.

Anyway, feel free to hit me with anything if you have some specific questions, I’m usually very active on reddit.com/r/unrealengine

Hello thank you for all the information.
And i have a follow up question(s), atm i get a error when steam is not running on my computer.
For clients that is as expected, but not for a dedicated server.

As it should not need Steam Client running and should connect to Steam Master server.
Now in AGameSession:: there is a virtual method ::RegisterServer()](AGameSession::RegisterServer | Unreal Engine Documentation) // Allow a dedicated server a chance to register itself with an online service.
(by default this method looks empty/ blank)

This is called after the initializing of the online subsystem attempt is made.
So do you have any idea of way Client Side works fine (as long as Steam is running), but is not being initialized server side?
As engine is initializeing the Online Subsystem on startup, it makes sence it should account for what is running. (Client, Listing Server or Dedicated).

Now do anyone have a idea on how to make this work for a dedicated server?
Right now i can not seem to get this to work as intended.

Thanks again.

I haven’t had any troubles with dedicated but I read that integrating with Steam specifically may cause problems.
You say you have an error, What block is causing it? What’s the Callstack like?

I Believe the RegisterServer() method is used to advertise a game after it’s started. Because you need somewhere to call the IOnlineSessionptr::CreateSession() method and dedicated server don’t have menus that can call set ups for you.

I’ve just lurked into this post How do I host a dedicated server on Steam? - Platform & Builds - Unreal Engine Forums
Which may give you more information. Dedicated Server integration with Steam is not something I have experimented a lot with yet.

is a image of the part in the server log when Steam fails on dedicated server.


Now i can “fix” this issue, just by Starting Steam on my the machine am trying to run the dedicated server on.
But documentation on Steamworks state that servers should not need a running Steam Client.

I am just wondering if it is even possible with the test App ID?

From what I have seen, the same will happen with “real” App ID.
I’m not sure as how this should work under Unreal Engine but I sure haven’t been able to start a Steam Dedicated Server without a Steam Client.

Hmm very vierd, am sure am doing something wrong.
Docs found Steamworks API Overview (Steamworks Documentation)

It says it needs to have its own unique SteamID now how is server expected to login?
If steam Client is running then its fine, but with dedicated servers it should not have to.
And i refuse to belive that i have to leave login details in code, so server can login.

But looking in the log for server I have this line.


Anyone know what it is referig to where to set this?

Stile looking into this, but am also having some cooking / packaging issues with 4.8.
So testing on a second host is a bit hard atm.

Has anyone got the a steam dedi server working on 4.8?

I’ve got it all working lovely when building Development. But if I build Development Server, this fails:


/**
 * Give the async task time to do its work
 * Can only be called on the async task manager thread
 */
void FOnlineAsyncTaskSteamCreateLobby::Tick()
{
	ISteamUtils* SteamUtilsPtr = SteamUtils();
	check( SteamUtilsPtr ); // fails

I tried changing that to SteamServerUtils() (or whatever the equivalent server function is) and that works fine, but then this line fails:


	if (!bInit)
	{
		// SteamMatchmaking() is null and there's no server equivalent
		CallbackHandle = SteamMatchmaking()->CreateLobby(LobbyType, MaxLobbyMembers); 
		bInit = true;
	}

Not yet am afraid, been dealing with a cooking/ packaging issue the last week.
But i will be working on this now so hopefully I have something soon.

I haven’t switched to 4.8 yet, I will let you know next week if I stumble upon this exact issue.

We currently still have to run Steam along with our dedicated server, despite it being a dedicated server executable.
I figured I just missed something when I compiled it :expressionless:

One issue I had getting finding servers was fixed by changing the defines in OnlineSessionAsyncServerSteam.cpp :



/** @TODO ONLINE Server values needed to advertise with Steam (NOTE: Steam expects UTF8) */
#define STEAMPRODUCTNAME "unrealdk"
#define STEAMGAMEDIR "unrealtest"
#define STEAMGAMEDESC "Unreal Test!"


After setting the correct online in the Steamworks area for our game, I updated these and was then able to find dedicated Steam servers:



#define STEAMPRODUCTNAME "groundbranch"
#define STEAMGAMEDIR "groundbranch"
#define STEAMGAMEDESC "Ground Branch"


I also tweaked OnlineSessionInterfaceSteam.cpp a tad to enable the player count.
Not sure why it was disabled, but anyway.

There is a bug somewhere in my implementation though, as you must completely quit out of the game in order to connect to another server, otherwise you get a very unhelpful error message if you try to connect (“An unknown error occurred.”).

Hey so getting some testing done on the Steam and dedicated Server.

Now in order for the server to be available on steam you need to create a session so players can find the game.
Now in the Session Interface you have


bool CreateSession(const FUniqueNetId& HostingPlayerId, FName SessionName, const FOnlineSessionSettings& NewSessionSettings)

Now to get the Unique Net ID i need a valid ULocalPlayer::.
API docs states Each player that is active on the current client has a LocalPlayer. It stays active across maps There may be several spawned in the case of splitscreen/coop. There may be 0 spawned on servers.

Using IOnlineIdentity::GetUniquePlayerId you need to pass in the integer id for the local player, now running a dedicated server and you will never get a ID.

I have yet to look into the NetDriver to see if this is usable.
f61146a5cb845f99a187d1e0a72e9dec.png

So ii guess the first question is how do create a session on a dedicated server?
Also it have me wondering if there is not a separate interface for server side of OnlineSubsystem just as the Steamworks API have?

Also i belive that getting your dedicated server to run without a running the Steam client is just about passing in login details in the command line.
I get back with more info on that later, that’s “progress” so far.

.

Hi guys. I have also been having problems finding my dedicated steam server online… Is there any way I’ve missed something?

If I localy host a steam server from the packaged game client, it works great, the server shows up and everyone online can see and join it.
But if I use the dedicated server build, the servers log windows says that everything is fine, and the server is lissening etc, but the server wont show up and even when trying to directly IP connect to it, nothing happens, the connection just times out.

I am now trying to change the defines in OnlineSessionAsyncServerSteam.cpp as suggested by Kris. Can the game name entered there be anything or does it need to correspond with the steam app Id? I am using the dev test app ID for now.

Cheers

I matched it to the name we set for our game in Steamworks.
You need your game greenlit/on steam before you can access that.

I set the name to “spacewar” which is the name of the steam test dev app id, but still nothing.
I dont understand why it wont work.

Why is hosting a server from the game client working perfectly, but the dedicated server dont work at all? It makes no sense to me.