Hosting and Joining Servers/Sessions?

I’ve spent days reading the documentation and various forum threads and wikis about this issue, but it’s still unclear how it all works. Basically, I just want to know how the client-server framework works in Unreal Engine 4, and how I can host or join games. I’ll try to break this down into multiple questions I have:

##How do I join a server once the game is started?

The only way I’ve been able to reliably join a server that’s already running is with command line arguments in the shortcut. I believe this is also possible with console commands and APlayerController::ClientTravel, but I can’t find enough information about this to decide what to use.

##What is a session?

The documentation is a bit lacking on its explanation of what a session even is. Do I even need to use sessions? Can I just join a server without joining a session? Since there can only be one session per server, what is the point? And why do I need to search for sessions if there can only be one session per server? Basically, I need an explanation of what a session is, and how I need to go about managing one.

##How do OnlineSubsystems work, and do I need to make one?

From what I’ve read, it seems that OnlineSubsystems are used just for thinks like steam or Google Play integration. If I’m not using any of these services, do I need to use an OnlineSubsystem, or can I just leave it at Null?

##What should I do to create a multiplayer game lobby that players can join and leave?

This really ties in all the previous questions together. As simply as possible, what is the general workflow for creating a lobby where players can join and interact with each other before some type of match based game starts? For example: If I wanted to make an FPS where people could vote on a map and chat before a match starts, what would I need to do? At what point would a session need to be created? Is it per match? If so, how do I manage players before the match begins?

I know this a lot, but I’ve seen variations on many of these questions all over the forums and the Answer Hub, and I do not believe they have been answered well enough yet. If anyone takes the time to answer some or all of this question, I want to thank you in advance.

Hey barba, I still learning stuff about session but I think I can put light over some questions.

  1. From what I know, you have tree way to join a server. With the command line=> open [IP]:[PORT], use Join Session node or with the shortcut.

  2. If I say nothing wrong, you can create as many session you want. If you know that you will have only one session for all your player, I suggest you to use the command line open [IP]:[PORT]. Essentialy a session will create a persistant connection between the client and the server.

  3. Exactly, if you don’t use steam/google whatever service, you can put it to Null. Keep in mind that if you want to be able to make work your Online nodes, you’ll need to put it in your DefaultEngine.ini (for PIE) and also uncomment the feature in your build.cs of your project (only for development/shipping version).

  4. It’s not that much hard, you’ll need to create only one session per match ([match include lobby :p] you create session only if you don’t find anything, you don’t want all your player to create session from no where). You’ll have two level; one with your lobby and the other one with your main level. You’ll need Servertravel command line to push all your player in the next level. (not sure what you mean by manage player before the match begins).

Here some picture how I use Session>

I’ll make a little explanation>

Note: all append to find talk is for my project, I have a box with information about searching for the player.

1 > I try to find a session, first I put the result in a variable, if the Lenght == 0, I know that I need to create one. if lenght is not equal to 0. Now I start searching for an avalaible session. (Basicly I search 50 session)

2 > So if they is no session find, here how I create my session (really basic as you can see)

3 > Now I look which session can be join. Also if I don’t find any session, I look how many session was found. If I find 50 session on 50, I restart the search with MaxResultFindSession + 50. If I find less than 50 session and no one was joignable I create a new session.

4 > If I find an avalaible session, I jump to my custom event where I can join with my result.

So this is a way to make session work, also it allow the player to click one time and get in game what ever happen.

I wish this would help you a little. I still confusing about session some time so if something is not clear or you still have some question, feel free to ask :D. Also keep in mind that is a very cool framework provide by epic game and more easy to use than create your own socket system.

(My native language is french, sorry if something don’t make sens)

1 Like