Making a Session System over Internet - Modding OSSNull c++ so it can be used over Internet

OnlineSubsystemB3atZ Plugin

Update 2018: At the moment this plugin is discontinued with last supported and tested version around 4.17ish. All instructions for those versions are still valid as written below. Feel tough to ask questions about it.

Hi !

I can present my Online Subsytem Engine Plugin which I was recently working on. This plugin started initially at a point where I was unhappy about that I couln’t use the session system over internet on mobile. In the meanwhile a lot of things have changed also on third party mobile services, but I think there are still some developers who could find use for it. Previously this was a tutorial about how to change the engine code to achieve a similar result as this plugin does and I am sorry if you were in progress on doing the tutorial. But if this is the case, you will achieve the same thing with this plugin.

So first of all for those who don’t know about Unreal Engine Online Subsytem. For using the session system like create session, find session in third party services like steam etc, you have to activate the right subsytem (in this case OnlineSubsystemSteam). As for using the session system withouth any third party system over internet, there was no way around it as to do it yourself (which was/is the case on mobile).

So withouth further ado, I show you now how to use the plugin:

  • When you try out this plugin for the first time, I suggest doing it on a seperate project. I dont take any responsability for your project. Also the plugin only will work from 4.13 upwards.

  • The main reason I say this, is that when you deactivate the default online subsystem all your default Session nodes as well as InAppPurchase nodes won’t load into your project.

  • First of all at the moment the plugin still needs some engine modification, so you will need Unreal Engine from Github.

  • Get the OnlineSubsytemB3atZ Plugin from Github: GitHub - philippbb/OnlineSubsytemB3atZPlugin: Unreal Engine 4 Engine Online Subsytem Plugin for using Unreal's Online functionality wihtouth third party service

  • Put the downloaded folders into: Engine/Plugins/Online/ in your Unreal Engine 4 directory.

  • In your projects defaultengine.ini add the following:

GameName=YourProjectName
Port=7777

[OnlineSubsystemB3atZ]
DefaultPlatformService=Direct

[/Script/Engine.GameEngine]
!NetDriverDefinitions=ClearArray
+NetDriverDefinitions= (DefName=“GameNetDriver”,DriverClassName="/Script/OnlineSubsystemB3atZUtils.IpNetDriverB3atZ",DriverClassNameFallback="/Script/OnlineSubsystemB3atZUtils.IpNetDriverB3atZ" )

[/Script/OnlineSubsystemB3atZUtils.IPNetDriverB3atZ]
NetConnectionClassName="/Script/OnlineSubsystemB3atZUtils.IpConnectionB3atZ"
AllowPeerConnections=False
AllowPeerVoice=False
ConnectionTimeout=60.0
InitialConnectTimeout=60.0
KeepAliveTime=0.2
MaxClientRate=15000
MaxInternetClientRate=10000
RelevantTimeout=5.0
SpawnPrioritySeconds=1.0
ServerTravelPause=4.0
NetServerMaxTickRate=30
MaxPortCountToTry=512

  • Now the engine modification which is still necessary: In the source file OnlineEngineInterface.cpp you will need to change

UClass* OnlineEngineInterfaceClass = StaticLoadClass(UOnlineEngineInterface::StaticClass(), NULL, TEXT("/Script/OnlineSubsystemUtils.OnlineEngineInterfaceImpl"), NULL, LOAD_Quiet, NULL);

to

#if WITH_EDITOR
UClass* OnlineEngineInterfaceClass = StaticLoadClass(UOnlineEngineInterface::StaticClass(), NULL, TEXT("/Script/OnlineSubsystemUtils.OnlineEngineInterfaceImpl"), NULL, LOAD_Quiet, NULL);
#else
UClass* OnlineEngineInterfaceClass = StaticLoadClass(UOnlineEngineInterface::StaticClass(), NULL, TEXT("/Script/OnlineSubsystemB3atZUtils.B3atZOnlineEngineInterfaceImpl"), NULL, LOAD_Quiet, NULL);
#endif

  • Compile the engine and your project in DevelopmentEditor configuration.

  • Now about activating the right plugins: After starting up your projects you have to activate OnlineSubsytemB3atZ, OnlineSubsytemB3atZUtils and OnlineSubsystemB3atZDirect. At this point you can still use all the editor PIE multiplayer testing. But when you plan to package and test the plugin you will need to deactivate the default OnlineSubsytem, OnlineSubystemUtils and OnlineSubsystemNull. Be carefull activating/deactiving these plugins, as when you use one of the blueprint nodes from my plugin and you deactivate it, they might vanish from your blueprint and you have to put them in again.

  • The blueprint nodes which have changed and how you use them:

The CreateB3atZSession node works the same way as CreateSession, except it will output the IP and Port used for the session. Other than that this create session node also works on dedicated servers directly from blueprint.

The IP will be outputed as a decimal integer and the port will be one number higher than the default URL Port which you use for the project. For getting the external IP of the host the node by default contacts “http://api.ipify.org” which also Rama uses in the Victory Plugin. I used this website for a longer time now and never had any problems with it. But if you need to change it, the 4.16 and master branch version of the plugin now supports changing the url in the advanced sections of the node. If you further need to customize the process of getting the external ip of the host session feel free to edit the code in the file CreateB3atZSessionCallbackProxy.cpp:

TSharedRef <IHttpRequest> Request = Http->CreateRequest();
Request->SetVerb(“Get”);
Request->SetURL(TargetHost); //TargetHost is the url string you enter in the blueprint node.
Request->SetHeader(“UserAgent”, “B3atZSession”);
Request->SetHeader(“Content-Type”, “text/html”);

In a finished project the IP and Port can then be forwarded to a Master Server. At this point I can recommend the very good VaRest Plugin!

FindB3atZSession node also works the same as the default FindSession node, but it accepts an IP and Port. Now again at the moment the IP Input should be as a decimal Integer. If you dont know your external decimal IP you can print it out from the created session or visit IP converter . The JoinB3atZSession and DestroyB3atZSession node work in the same way as default one’s do. The port for the client will be two numbers higher than the default url port defined in your defaultengine.ini file. This is so you can test it all on one pc.

  • Make sure the right udp ports are open (for testing maybe 7777 trough 7779)

  • I suggest you first test it on a project with windows development package. You can not test the session functionality from the editor or play standalone from editor.

  • Before packaging or debugging the packaged game your uproject file should look like this:

“Plugins”:
{
“Name”: “OnlineSubsystemB3atZ”,
“Enabled”: true
},
{
“Name”: “OnlineSubsystemB3atZUtils”,
“Enabled”: true
},
{
“Name”: “OnlineSubsystemB3atZDirect”,
“Enabled”: true
},
{
“Name”: “OnlineSubsystem”,
“Enabled”: false
},
{
“Name”: “OnlineSubsystemNull”,
“Enabled”: false
},
{
“Name”: “OnlineSubsystemUtils”,
“Enabled”: false
},
{
“Name”: “OnlineSubsystemGooglePlay”,
“Enabled”: false
},
{
“Name”: “OnlineSubsystemIOS”,
“Enabled”: false
},
{
“Name”: “OnlineFramework”,
“Enabled”: false
}
]

For more information on how to use the session system and what it does you will find a lot of information on the forum and answerhub.

Coming from a non-programmer background I learned a lot about Unreal Engine and c++ in the last few years thanks to Epic. And at this point I really would like to thank everybody at Epic Games and the community.

I dont know if this has been said elsewhere, but I really think that open source Unreal Engine is one of the biggest “learning center” you can find on the internet, if one likes to learn programming. I do think that Epic Games should not only get the credit from their users, but also should be acknowledged and credited by governments for providing this kind of open source environment.

Credits: Rama for letting me use his GetMyIP() function and Epic, Epic Community

Some questions left:

What is different now?

You can test and use the session system from the Online Subsystem over the internet and not only over LAN.

Does Chat and other system work?

The Chat, Lobby, Rejoing and famous Party system are not supported by this plugin at the moment. Voice was tested and works.

*Hello! It doesn’t work on Android! *

For Android you have to disable OnlineSubsystemGooglePlay in your uproject file before building for android.
Also as it is, it won’t work over mobile data as of now unless with dedicated server.

How about iPhone

I don’t have a device for testing at the moment, but maybe it will work by disabling OnlineSubsystemIOS.

Can I still use Achievements, Leaderboards etc from GooglePlay or iPhone with this?

Unfortunately not at the moment. Also InAppPurchase is not supported at the moment.

Does this also work with dedicated servers?

Yes.

Can I still use the editor multiplayer testing as before?

Yes. But you need to activate OnlineSubsystem, OnlineSubsystemUtils and OnlineSubsystemNull Plugins. The B3atZ Plugins can be activated or not.
But once you want to package you will need to deactivate the default OnlineSubsystemPlugins and just leave the B3atZ Plugins activated.

When I try to compile for development it gives me a lot of errors?

For development build confiugration and packaging you will need to disable the default online subsystem plugins before compiling. Maybe this will change.

What copyright licence does this have?
Send me a message if you want or mention the plugin if you use it. Can be used and modified for commercial/noncommercial use as u like.

This looks really cool. Question: Does this system allow you to use the built in voice comms over your internet sessions?

Hi thanks! Yes maybe i will be able to show a working example with default voice system from ue after i put everything in 4.10.2

Edit: Part 2 is uploaded.

Finally I found your post.
I made a question on answer hub today about this topic.
But got a answer here.

Also I want to use your codes with advanced session plugin in this forum.
May I?

I spoke with him over PM that changing it up to be a seperate Subsystem would probably work better, it wouldn’t interfere with the default NULL at all then, could override only areas that change, and then would work out of the box with all of epics code AND the Advanced Sessions Plugin.

As a direct engine modification as it is currently and putting some of the features into the connection nodes directly instead of the subsystem it isn’t compatible with my plugin as it doesn’t follow the subsystem structure of being interfaced with.

Some small changes and inheriting the null subsystem though and it would be perfectly compatible and even able to be released as a plugin itself.

Thank you so much for your tutorial~ learning a lot~

Good you found it. :slight_smile: Yes your welcome to do so!

Yes that would be rad! As I told you it would be cool to make it run with your plugin. Which is awesome by the way.

Thank you.

bookmarking this thread. good stuff, as only having steam as an option for lan play, kinda sucks… this could be used as a base to connect to your own master servers… could be very useful.

Awesome work on creating a custom subsystem :D. Is there any updates?

Do you plan to update in the future?

Sorry for my late respose. I recently was busy turning this into a plugin which I just uploaded. So I updated the title entry of this thread on how to use it.

If a mod could change the title thread to Online Subsystem B3atZ Plugin I would be very thankfull, as it is now a plugin and not a tutorial.

Thanks everybody for the messages and please don’t hesitate to ask questions.

That’s some really great work!
Do you think it still works, for up2date unreal versions? Or is there an alternative at the moment?
I’ve tried it with 4.20, but i didn’t got it running.
Also do you think i could just use it as external Plugin, if i dont want to use the normal Subsystem, like you do, so i dont have to modify the engine and have to compile it everytime.

Greetings