How to make a CLIENT leave the CURRENT session and join the SAME session again? (Listen Server)
I've used this WIKI page to get a reference for the C++ code: https://wiki.unrealengine.com/How_To_Use_Sessions_In_C%2B%2B
When a client decides to leave the session or a lobby, I currently destroy the session for the client and make him go to the Main Menu by using OpenLevel() function. After doing this, if the Client decides to join the SAME session again, the search for sessions doesn't return that destroyed session in the search results array. So the client is unable to join the SAME session which he had previously left.
After the client destroys the session and leaves the game, if the server tries to end the session by calling the DestroySession() function, the function fails as well. However if the client just returns to Main Menu without destroying the session, the search for sessions functionality from the client fails but the server is successfully able to destroy the session using DestroySession(). This implies that DestroySession() should be called only once for a particular session. But it is mentioned in this link that https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/OnlineNodes/ "Clients also need to call this node(Destroy Session node) when they leave a game." Even in the Multiplayer tutorial by Wess Bunn, he destroys the session for a client when the client leaves the session. The same is done in the MultiplayerShootout game as well.
I've been looking into ShooterGame code now. It calls EndGame() function before destroying a session. But there seems to be no documention about EndGame() or how to properly make the client properly leave the joined session.
There are other functionalities as well, but I'm not sure if I have to use them.
I'm using STEAM online sub system.
I would really appreciate if someone can help me with this.
The problem was actually at my end.
I was destroying the session in EndPlay() of PlayerController which was causing the session to be destroyed in the server.
My previous code was:
My current code is:
answered Oct 20 '17 at 11:54 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here