x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

  1. KickPlayer() in AGameSession

  2. RegisterPlayer() and UnregisterPlayer() in IOnlineSession

I'm using STEAM online sub system.

I would really appreciate if someone can help me with this.

Thanks, Nishanth

Product Version: UE 4.16
Tags:
more ▼

asked Oct 17 '17 at 07:05 PM in C++ Programming

avatar image

NizzyD
26 1 1 4

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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:

 void AYourPlayerController::EndPlay(const EEndPlayReason::Type EndPlayReason)
 {
     if (HasAuthority())
     {
         UYourGameInstance* YourGameInstance = Cast<UYourGameInstance>(GetGameInstance());
         if (YourGameInstance )
         {
             YourGameInstance ->DestroySession();            //My own custom function
         }
     }
 
     Super::EndPlay(EndPlayReason);
 }

My current code is:

  void AYourPlayerController::EndPlay(const EEndPlayReason::Type EndPlayReason)
 {
     if (IsLocalController())                                //Change was made here
     {
         UYourGameInstance* YourGameInstance = Cast<UYourGameInstance>(GetGameInstance());
         if (YourGameInstance )
         {
             YourGameInstance ->DestroySession();            //My own custom function
         }
     }
 
     Super::EndPlay(EndPlayReason);
 }


more ▼

answered Oct 20 '17 at 11:54 PM

avatar image

NizzyD
26 1 1 4

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question