[BLOG] C++ Session Create/Find/Join/Destroy

Hi, Iv’e been following the “tutorial” :wink: and its been great so far iv’e learn’t a lot.

I have a couple of questions…

  1. I have setup the steam online subsystem in my settings and it all works, will this automatically use the steam online subsystem instead of the standard UE4 online subsytem?

  2. I know this sounds stupid but where would i call these create/find functions from? the player controller? if so how?

  3. Also in the shooter example all the create/join functions are in AGameSession files, not the game instance file. Does this matter? whats the difference?

Anyway, thanks for your work so far! :slight_smile:

I did not directly forget it. Since we have no function that we need to call for the Destroy Session part, we need to do this at the point we are calling “Sessions->DestroySession(…)”.
I created a Blueprints callable function for all 4 operations. The one for Destroying contains this part. You can see this in my Wiki Post i will link in the Main Thread soon.

  1. Yes, this should work. As long as the Subsystem is working correctly. UE4 uses wrapper functions that work in the background for you, matching the Subsystem functions that are needed. This will make it easy for us (:
  2. No this is not stupid. It is totally valid. I create a BlueprintCallable function for each of the 4 parts. I just did not posted them yet. They are featured in my Wiki Post which is will add to the Main Thread soon.
  3. No it doesn’t. The ShooterGame added a new Child Class for the GameSession. They are also working with the GameInstance. They just organized it differently, but didn’t want that here. It would only confuse people.

@All: I will erase the main thread and only post a link to the wiki page. It will also contain a link to the Project i have all this in (:

Ok good, Thank you :slight_smile:

Great work eXi, thank you a lot!

Here comes the interesting part, even your project is not working for me. :frowning:

What i do:
Open project in UE 4.76 (btw, which version do you use exactly?)
Click Compile
Set number of players to 2 and start playing
Press H on viewport 1
Press F on viewport 2

Result: “Num Search Results: 0”

Thats exacly the same problem that i have with my project. Strange. :confused:

Ah, well, i have forgotten the most important part: I have no idea how this works in the PIE.

If you go to the Project folder and rightclick on the UPROJECT file, you can select “Launch Game” or something like that.
Do that twice and try the hosting and joining there.

The problem with PIE is: You are already in the same Session when starting. That’s why hosting again could be a problem.
You could try to call the “DestroySession” event on both players first though.

Uh, wow, that works well!

I packaged my own project but it isn’t working there either, only using “Launch Game” works fine for sessions - never tested that. I’ll try to find a solution for this!

eXi, so I followed you fully and for some reason my session search always returns 0. I play in editor with two clients and a server. Client one Hosts and Client two tries to find.
for the hell of it I’ve downloaded your project, and your project CANNOT find a game… I’m frustrated as hell… What am I doing wrong now?

Hey, yes there seems to be a Problem with the PIE Version, because you are already connected through a session when you start your game there.
Look at the post i made above, and follow the steps to get at least my project working. Yours should work the same way though.

Or you can try to destroy the sessions in the PIE Version before you start a new Server and try to find it.

I will add a warning to the wiki page with the information.

Destroying the session on start isn’t working unfortunately, actually the game tells me there is no session running. I also tried different things like calling IOnlineSubsystem::Shutdown() and/or IOnlineSubsystem::Init() but the problem still exists. (EDIT: The interessting part is that using BP the PIE is working, so the BP is calling some magic we don’t know …)

I will now try to find a solution from the UT code, hopefully i can find anything there. Otherwise, is there a chance Epic may lead us the right way?


I will have a look at the Session Nodes Code again. But the time i have free for this is limited. Currently working on my own project again.
If you find something, please post it here!

Thanks eXi! This was very well put together!

Do you have any plan to do this tutorial on new UE4 versions like 4.9.1 … it’s a greate work for people like me that want’s to know more about C++ and networking…
thanks a lot

Only if it is not working for 4.9.1. Are you just asking because it states 4.8, or is this not working in 4.9.x anymore?

I started to do this tutorial on 4.9.1 but there was too many error in visual studio from beginning …some error for includes some error for delegates and a lot of error …

I have a problem in blueprint join session node and then i decided to make custom version of that in C++.

My problem is Join Sessions Blueprint node, Success execute but device can’t open level to join and nothing happened after that… but if i use console command Open {IP Address} everything is OK. I want this for Android/iOS .

I made a topic for this problem if you can help me i will be appreciate a lot … thanks

This topic here

Hm, i have no idea about mobile Sessions. Don’t know if you can use the sessions on mobile so easily and/or if you need to add some other stuff.

If i find time, i will redo the C++ project for 4.9.x (: Thanks for telling me!

Thanks, can you tell me where I can start to edit or customize existing join sessions node?

The Nodes can be found here (This is one of them):

You will need to edit the Source Code for this. You can also check out the Advanced Session Node Plugin that you can find on the Forums.

Hey there eXi. Awesome guide. I’m having an issue though. ( In 4.10 )

Creating/Joining/Leaving a game session works wonderfully. However, the ClientTravel is not working for me. This probably isn’t an issue that you can attend to, but I’m posting just in case.

When calling ClientTravel, the client actually closes the connection to the server and becomes it’s own stand alone game. And then it finally doesn’t travel anywhere.
I tried using FGameplayStatics::OpenLevel(TravelUrl), giving it the Travel URL and it does the same thing.
I tried using FGameplayStatics::OpenLevel(“MapName”,TravelUrl), and it seems to try to load the new map but ultimately still does the same thing and stays on the MainMenu.

This happens in a packaged game as well.

Do you have any idea what can be done here?

Problem :frowning: Unreal engine version 4.7.6

Oh man, i didn’t see these 2 posts! Sorry!

@MuzzyA: I assume you are trying to let the Client travel to a different map than the Server? The Server can only hold 1! Map at a time. You can only send the Clients
to this map. If you try to load a different map for the Client, he will end up in a SinglePlayer game. To have multiple Maps you need multiple servers!

May i ask if you have a compile log or something? This message is not telling me anything. ):

PS: Or how exactly did you try to build this?