"Unity and Smartfox Best Of Both Worlds" How to integrate scores and currency?

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
Zenith
Posts: 46
Joined: 09 Oct 2017, 09:57

"Unity and Smartfox Best Of Both Worlds" How to integrate scores and currency?

Postby Zenith » 23 Jun 2018, 20:44

Hi,
This is to understand what are your views regarding how can we implement scoring and virtual game currency integration between SFS and Unity now that game is actually ran on Unity instances and user accounts etc are on SFS.
We don't intend to make clients submit their scores and currency changes.
So what sort of architecture do you suggest where we can have communication between unity instance and SFS Room .

Regards.
Sorry if it is too noobish!
User avatar
Lapo
Site Admin
Posts: 20219
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: "Unity and Smartfox Best Of Both Worlds" How to integrate scores and currency?

Postby Lapo » 25 Jun 2018, 08:58

There is nothing noobish about this :)
With the SFS2X + Unity approach each player is running two connections, so each client can talk to both your Extension and the Unity game code.

I would usually recommend to use Unity exclusively for the in-game logic, movement updates, positions, collisions etc... and SFS2X to the rest of the work such as managing in-game chat, buddy lists, database operations, etc.

With this said if the user wants to run a transaction with virtual currency the request should be sent to SFS2X which can validate the operation and update the user's profile via the DB.

Similarly the score should be managed by SFS2X. In this case it can be a little more complex because the score is probably calculated by the Unity server which in turn needs to store it somewhere at the end of the game.
What I would suggest here is that the Unity server sends the game scores via an HTTP call to a servlet running in SFS2X.

Makes sense?
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Zenith
Posts: 46
Joined: 09 Oct 2017, 09:57

Re: "Unity and Smartfox Best Of Both Worlds" How to integrate scores and currency?

Postby Zenith » 25 Jun 2018, 15:34

Lapo wrote:
Similarly the score should be managed by SFS2X. In this case it can be a little more complex because the score is probably calculated by the Unity server which in turn needs to store it somewhere at the end of the game.
What I would suggest here is that the Unity server sends the game scores via an HTTP call to a servlet running in SFS2X.

Makes sense?


I get this but how does unity server know which player is which.
I mean to say there should be some API by which server can confirm that player who is sending his username to server as "Zenith" is actually "Zenith" and not the case that "Lapo" is logged in in SFS but is sending his username as "Zenith" to Unity server. :-P

So we need a way to verify the player in Unity Game Server is a valid logged in SmartFoxServer Player.
Maybe here also a ticket system can be made -->

Players logs in SFS.---> Gets Back a Ticket
Player sends the Ticket to Unity Server (instead of username) --> Unity Server sends Ticket to SFS.
SFS verified Ticket and sends back player Unique Id or Name to Unity Server.
Unity server sends score to SFS with that player Unique Id.

Is this appropriate approach?
Can you suggest some things to create Tickets or if they should be stored in db . Also tickets should Timeout.
Can this whole thing be made into SFS as API. Because this much system becomes as a must for communicating securely the scores from Unity Server to SFS Server.

Playfab Guys are doing it like this for external server support .
https://api.playfab.com/docs/tutorials/ ... me-servers

I think such or some alternate system for this would be great help to devs going to use Unity and SFS together in Best of Both World Scenario.
User avatar
Lapo
Site Admin
Posts: 20219
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: "Unity and Smartfox Best Of Both Worlds" How to integrate scores and currency?

Postby Lapo » 25 Jun 2018, 16:09

So we need a way to verify the player in Unity Game Server is a valid logged in SmartFoxServer Player.
Maybe here also a ticket system can be made -->

Players logs in SFS.---> Gets Back a Ticket
Player sends the Ticket to Unity Server (instead of username) --> Unity Server sends Ticket to SFS.
SFS verified Ticket and sends back player Unique Id or Name to Unity Server.
Unity server sends score to SFS with that player Unique Id.

Yes, this is a good way to verify the user.
The "ticket" already exists, because each user is auto-assigned a session token (not the userId) which is 32 character random string.
You can use that as an identification.

Playfab Guys are doing it like this for external server support .

I didn't know about this one. We're working on a similar concept, for integrating Unity servers with SFS2X.
The project is currently on hold as we're waiting for the Unity team to improve the performance of the Unity server itself as we've found it currently uses too many resources even when idle, thus requiring quite a lot of extra power for running in this kind of distributed approach.

We've found this issue only very recently and submitted a bug report. Unity has gotten back to us confirming the bug, and promising to look into it, though they haven't provided a possible release schedule.

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 10 guests