Initialize Listen Server While Playing

I currently have a menu set up. One of the buttons says Start Hosting. I would like it if the player could simply click this button and be converted to the listen server. I want it so friends can join in mid game. I am looking for a C++ solution but open to anything.

How would I go about doing something like this?


You could have a look at the ShooterGame Example. It has fully functioning Servers with Server lists etc.

I don’t know if you can swith from SinglePlayer to a listenserver without reloading the map. So if you want it seamless, you could start the Singleplayer game as a listenserver and only advertise it if the player wants it :X

Just some ideas. I’m not that good at c++ networking.

#Simple Answer, Supports Open IP and Steam

You can host a game that people can join via open IP or via your steam id like this:

//Assumes you are storing your maps in Content/Maps
//   Dont include any extension off of the map name
//    Run this in your pc or character or some actor class
//           <3 Rama
void AYourClass::HostListenGame(const FString& MapName)
    const FString URL = "/Game/Maps/" + MapName + "?Listen";

#Long Answer / Server Browsers

Check out ShooterGameSession.h to see the full OnlineSubsystem implementation for hosting a game that will involve appearing in appropriate server listing for current Online subsystem, such as Steam, if you have your own app ID



Just a comment to the last sentence. You will get a real SteamID if your Game is Greenlit. BUT you can use the ID 480 to test nearly everything. If you want to test the ShooterGame Via Steam, you just need to change its Steam ID to 480 in the setting files. (: Then you can use 2 PCs and 2 Steam Accounts (don’t need to have a game bought and installed) to test Steam Connection of your Servers.