Server side logic advice
Options
mcmorry
✭
I'm woking with Photon Server on premise, and I'd like some advice on the best way to implement and extend the LoadBalancing application.
I have a REST service hosted by a third party that allows me to do authentication and to process shop transactions (to buy some items or to pay before the starting of the match).
But this service doesn't store all the user progress and the list of the owned items. So I also have a DB that I need to update.
So I'm implementing a custom authentication through the REST service, but then I need to load the user progress from my DB.
How do you suggest to proceed? To use Operations and to extend the OnOperationRequest method of HivePeer (not sure is the correct class here, as there is also GameClientPeer and some more).
The player has also to pay before to enter a room and should get refunded if he leaves the room before that the match started.
I was thinking to implement a plugin for this, and use a Synch HttpRequest in the BeforeJoin and OnLeave events (as there is no way to defer those requests). Is it possible? And in the case of failed transaction, I could make the Join action to fail.
A completely different approach could be to create another REST service that acts as a proxy to the 3rd party one and that also updates the DB.
The client will then use WebRPC calls instead of Operations. But in this case, I'm not sure how to guarantee that the user will not join a match without paying the fee. By hacking the client side could be possible to ignore a failed the WebRPC response (or to skip completely the call) and proceed to join the room.
Thank you for any advice you can give me
I have a REST service hosted by a third party that allows me to do authentication and to process shop transactions (to buy some items or to pay before the starting of the match).
But this service doesn't store all the user progress and the list of the owned items. So I also have a DB that I need to update.
So I'm implementing a custom authentication through the REST service, but then I need to load the user progress from my DB.
How do you suggest to proceed? To use Operations and to extend the OnOperationRequest method of HivePeer (not sure is the correct class here, as there is also GameClientPeer and some more).
The player has also to pay before to enter a room and should get refunded if he leaves the room before that the match started.
I was thinking to implement a plugin for this, and use a Synch HttpRequest in the BeforeJoin and OnLeave events (as there is no way to defer those requests). Is it possible? And in the case of failed transaction, I could make the Join action to fail.
A completely different approach could be to create another REST service that acts as a proxy to the 3rd party one and that also updates the DB.
The client will then use WebRPC calls instead of Operations. But in this case, I'm not sure how to guarantee that the user will not join a match without paying the fee. By hacking the client side could be possible to ignore a failed the WebRPC response (or to skip completely the call) and proceed to join the room.
Thank you for any advice you can give me
0
Comments
-
Thanks @chvetsov
So if I understand correctly, I should create my proxy REST service and use WebRPC calls to get user progress and to perform authentication and shop actions before joining a room.
Then for the in-game logic, I will use a plugin that internally will also access my REST service.
In this way, I should not touch the LoadBalancing source code anymore.
Then just a question. How would I perform WebRPC calls from within my plugin to my REST service? I saw that WebRPC includes an AuthCookie for validating the incoming requests and I would like to use the same validation system when the client or the plugin send requests to my REST service.0 -
>So if I understand correctly, I should create my
yeah, sounds logical and complete.
>How would I perform WebRPC calls from within my plugin to my REST service?
well, it is not web rpc. from plugin you may call PluginHost.HttpRequest method, which will contain everything you need. also 'info' reference you get as parameter of plugin method has AuthCookie refrence for call initiator.
best,
ilya1 -
Thank you so much!
There is a lot to study and I missed that ICreateGameCallInfo contains the AuthCookie.0 -
all calInfo references contains it when it makes sense
for instance for ICloseGameCallInfo it does not make sense
best,
ilya1