Why does my session gets destroyed after "Join session"?

Hey all need your help on the folloing weird behavior:
I try to programm a simple lobby browser and can see the open lobby from my second PC/Laptop. I can also join the session sucessfully. Now to the weird part:
1 - 2 seconds after joining the session gets destroyed for some reason. I’ve got an Eventplay-node with an output that prints “destroyed” as the end play reason. (I never destroy the session anywhere except when the player presses the Back-Button)

Does anyone know why the session gets destroyed? I’am really frustrated because i’am sitting 3 days on this problem now. Maybe i got the NetMode wrong? Currently iam using “Play as listen server” on both machines. Maybe i replicate the events wrong? Iam replicating the event “AddPlayerController” as multicast / run on owning client wich gets called by the LobbyGamemode on the server?

Thanks for any help,
M

Hey first of all thanks for joining me on this one. I fixed part of the problem bei creating a “Lobby” level wich open when creating or joining a session. However now i have got another even bigger problem: The connected client does not use the gamestate (i thought the gamestate is replicated?).
Here is my setup in the Lobby-level-blueprint:

Here is the addplayercontroller (calls add function in state, playercontroller array is set to replicated):

I have got a test function wich replicates a string in the gamestate:

Function in gamestate:

The text gets updated in the host-window correctly but it seems like the connected player is using a different gamestate ?? Iam really confused by now and appreciate any help

Best regards and thanks.
M

Could you send a screencap of where you’re calling the create session and join session too please?

I think I see what you’re doing here. So you’re trying to add a reference to each of the players by the event begin play so when the host starts, it runs to add it to the array in the gamestate then what you want to happen is when the client joins it runs the event begin play and adds it to the array correct?

If that is indeed the case, a client can’t affect a GameState. I think a Player state could be used and then ran as server to execute and disburse the message that way but in order to carry the reference, you need to have the player controller set as an input pin all the way through every custom event node until it got the the array to be referenced.

you also need to be pulling the data for both instances from the gamestate once it’s been set. I have an example of this on a project that I did something very similar w/ a 3d widget that updated player ready and such and replicated it to clients.

Sure. Let me know if anything is to small to read :wink:

Launch a lobby (/session):

Join a session:

Show HostMenu:

Iam just lost because i dont know how all players get to use the same gamestate (/how/where to register all playercontrollers to the gamestate).

Yea iam trying to do a lobby-browser kind of thing. I want the host to open a lobby if he wants. The game is listed in the lobby-list (that part is working) and i can also join with the second player. The problem is that i dont know how to sync the lobby-widgets. (Currently both players are in the same lobby but have their own empty player-slots).
EDIT: That sounds kind of like what iam trying to do, do you have a screenshot of the join process for me? :slight_smile:

Okay, so you’re going to need to do the playerState run on server to GameState to pull the variables which should set the text variable of the specified player controller’s widget by daisy-chaining the controller pin all the way to the end and then setting up a custom event that sets the variable in the widget for that player’s controller.

I’ll be home in a couple of hours and can post screenshots for you.

Okay, I mispoke. It wasn’t playerstate, I used player character to handle the server response for the updated text.
This is in the Widget:

This is in the Player Character

This is the bind function for the text variable in the widget

Here’s the Widget Design view

The In-Game Result

The MPPlayerList in GameState is an ‘Event PostLogin’ I believe which adds the new PC to the array

Hey first of all thanks for sharing your code very appreciated. I’ve tried the following:
In the gamemode (the gamemode is opened when opening the lobby-level):

In the gamestate:

Also a weird thing that the session still gets destroyed after hosting a game:

Why does the session gets destroyed (“No registered sessions”) but I am still able to find the session with my second window (the gameslot is NOT hardcoded it gets all sessions and lists them):

I can still click on it to join but the number of playercontrollers is still 1 after joining.

Maybe the session gets destroyed on one gameinstance and therefore i cannot join and the gamestate is not the same? (I also made a testcall but it only works locally and does not get replicated. Also the number of playercontrollers printed to the lobby window is 1 one both windows.)

Is it important that the player own a pawn? Everthing i’ve seen is always with a playercaracter (but i dont need one here because its only the lobby at that point).
Best regards and big thanks! M

Can I get pictures of the blueprint with create and join sesssion please? Also the point where you’re calling the addplayercontroller.

For the session destroyed, I would need to see the blueprint for the whole process of when it displays that message.

I have another project that I can give an example of the session creation/handling when I get home to maybe help give an idea.
Edit: I also just thought of something else to check. In the advanced options under the play arrow, make sure ‘Use a Single Process’ is unchecked.

UPDATE: So i dont really know what changed but it works now for some reason (i can replicate the string for example). Thank you so much FatalBreak! I will post my solution for any future visitors soon. Big THANKS again without you wouldve never gotten so far :smiley:

That’s great news! I look forward to seeing it. Glad I could help you out on it.