Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • General Discussion /
avatar image
Question by martinliu1993 · Mar 14, 2017 at 09:33 PM · Custom Game Servers

How to create a custom UE4 Game Server using PlayFab?,How to create a custom UE4 Server using PlayFab?

I've looked through tutorials but haven't found anything that allows me to create dedicated game server in UE4. Basically, I just want an empty third person shooter project with PlayFabs plugin installed, and dedicated server hosted using PlayFab.

This link here had some hints as to how to create a UE4 game server, but doesn't delve into the details. I also see that there is a test server project for Unity here. Is there something for UE4? If not, are there good tutorials as to how to setup one?

Thanks

,
Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Brendan · Mar 14, 2017 at 11:15 PM

There's actually nothing PlayFab-specific about creating a game server in UE4 - any executable that can run on Windows 2K12R2 will work in our hosting. I take it you're starting from the UE4 Shooter Game example (https://docs.unrealengine.com/latest/INT/Resources/SampleGames/ShooterGame/index.html)?

While we don't have a sample project showing this, there are really only a few things that would be required:

First, you'll need to make sure you use the https://api.playfab.com/Documentation/Server/method/RedeemMatchmakerTicket call to confirm that the player is supposed to be joining the server as a result of a call to Matchmake (assuming you're using our matchmaker - otherwise, you'll want to have a way to validate, such as an encrypted signature), and https://api.playfab.com/Documentation/Server/method/NotifyMatchmakerPlayerLeft to let us know when the player leaves the session. The Game Mode is the best place for that - do the ticket redemption in PreLogin, so that in case the player has to download a lot of content from the server for the level his ticket doesn't time out, and the player left call can then go in the Game Mode Logout call.

Other than that, you'll want to add some logic to report the results of the match to the player statistics and possibly User (Read-Only or Internal) Data. That could be called from a number of places, but one approach would be to put it in HandleMatchHasEnded (or trigger it separately from WaitingPostMatch).

Comment

People who like this

0 Show 8 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image martinliu1993 · Mar 14, 2017 at 11:50 PM 0
Share

Hey @Brendan

So I've successfully setup a server running on USCentral using the tutorial here.I followed the tutorial and called MatchMake as you wrote above. Basically, this is the code I have in my test UE4 Project:

clientAPI = IPlayFabModuleInterface::Get().GetClientAPI();
clientAPI->SetTitleId(TEXT("144"));


PlayFab::ClientModels::FLoginWithCustomIDRequest request;
request.CustomId = TEXT("GettingStartedGuide");
request.CreateAccount = true;


clientAPI->LoginWithCustomID(request,
		PlayFab::UPlayFabClientAPI::FLoginWithCustomIDDelegate::CreateUObject(this, &AMyProject2Character::OnSuccess),
		PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &AMyProject2Character::OnError)
	);


PlayFab::ClientModels::FMatchmakeRequest MatchMakeRequest;
MatchMakeRequest.GameMode = "123";
MatchMakeRequest.BuildVersion = "123";


clientAPI->Matchmake(MatchMakeRequest,
		PlayFab::UPlayFabClientAPI::FMatchmakeDelegate::CreateUObject(this, &AMyProject2Character::OnMatchMakeSuccess),
		PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &AMyProject2Character::OnMatchMakeError)
	);



The MatchMake call is returning an error:

"Missing or invalid X-Authentication HTTP header", any ideas?

avatar image Brendan ♦♦ martinliu1993 · Mar 15, 2017 at 12:37 AM 0
Share

It looks like you're not waiting on the Login call to complete before attempting to call Matchmake. The Login call returns a Session Ticket, which is subsequently used as the authentication header for calls to the Client API. You'll also want to make sure that as part of your overall code flow, you are checking for the invalid ticket error for when it has expired, so that you can sign the player back in again. The ticket is good for 24 hours currently, but there are some crazy-dedicated players out there. :)

avatar image martinliu1993 Brendan ♦♦ · Mar 15, 2017 at 01:22 AM 1
Share

Hey @Brendan, So I successfully made MatchMake work but I'm still getting "Game mode not found". This is how my server is setup:

And this is my new code for calling MatchMake

void AMyProject2Character::OnSuccess(const PlayFab::ClientModels::FLoginResult& Result) const
{
	UE_LOG(LogTemp, Log, TEXT("Congratulations, you made your first successful API call!"));


PlayFab::ClientModels::FMatchmakeRequest MatchMakeRequest;
MatchMakeRequest.GameMode = "test";
MatchMakeRequest.BuildVersion = "123";
MatchMakeRequest.pfRegion = PlayFab::ClientModels::Region::RegionUSCentral;


	clientAPI->Matchmake(MatchMakeRequest,
		PlayFab::UPlayFabClientAPI::FMatchmakeDelegate::CreateUObject(this, &AMyProject2Character::OnMatchMakeSuccess),
		PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &AMyProject2Character::OnMatchMakeError)
	);
}

As you can see, the GameMode is set to "test", and in my code I'm also setting GameMode to "test". Why would it say "Game mode not found"?

capture.png (14.1 kB)
capture.png (42.4 kB)
Show more comments
Show more comments
avatar image meshedwell martinliu1993 · May 12, 2017 at 12:49 PM 0
Share

Hello.martinliu1993 & brendan. how can i solve "Game mode not found" error message?

1.jpg (55.8 kB)
2.jpg (173.7 kB)
avatar image Brendan ♦♦ meshedwell · May 12, 2017 at 07:14 PM 0
Share

Just so you know, that's a very different question from the one above, which was about using the Matchmake call. What you are doing is running a game server which you want to connect to the service via the RegisterGame API call, so that it can be discovered by our matchmaker. To do so, you do need to have a build uploaded with the Build ID you want to use, and the Game Mode you want to use configured for it in the Game Manager. But since your screenshot above seems to imply that you have set that up for a title, I would have to assume that the call is failing because it's being made on another Title ID. Can you verify your Title ID settings in your project and let us know what that Title ID is?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    3 People are following this question.

    avatar image avatar image avatar image

    Related Questions

    Are there any server in Asia? Any api for using wechat account to login? 1 Answer

    Correct Workflow for Client joining dedicated server hosted on PlayFab 1 Answer

    Not enough threads in Thread Pool 1 Answer

    All custom game servers full with "already quit" game instances, new servers not auto-scaling to start up, games not shutting down? (URGENT - affecting live / unchanged game) 1 Answer

    Custom Server With Matchmaking 2 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges