Separate serializers: not easily. You’d have to have two parts of your app run in their own separate isolated class loaders.
Separate connections, sure. But here is how the conversation usually goes:
Me: “Gee, though, it’s weird that your masterhost would have game objects.”
Other person: “No, I just want to check account info and provide leader boards.”
Me: “Ah, so you are trying to make SpiderMonkey’s real time gaming API into a REST services… ;)”
Can you explain more about what you are trying to do?
A masterserver you connect to every time, that has a list of the game-servers you can connect to ? and from within the game, you can switch server (like half-life did back in the day) - or is that “just” REST?
It’s much easier to handle the request/response cycle of a flow like that via a standard REST/web API framework than with SpiderMonkey, where you have to handle the network connection lifecycle manually. For things like this, something like the lightweight Javalin framework may serve you well: https://javalin.io/.
Yeah, this is what I had in my mind. Mainly because it is very easy to work with JME RMI and works fine both on desktop and mobiles.
I have not worked with REST before, but thanks for informing me, I am going to search more about it.
I guess I need to use a HttpClient library for it, Yes? In that case, I need to find one that can work both on desktop and mobile.
Thanks so much, guys. Your posts were very informative. I appreciate your help.
There is one more thing I am interested to know your idea about. Going one step further the REST, It’s about the technology stack for the master server and providing a browser-based dashboard for doing stuff like registration, deposit wallet, activate the game, get latest news, list of game servers,…
Afaik most web frameworks including Spring use MVC pattern in which one yet needs to deal with Html, JS, CSS, and relevant client-side frameworks like Angular and Vue for the presentation layer.
Seems there is another pattern called Domain-driven design for rapidly developing in which one just writes business logic and the presentation layer is generated dynamically. Sounds very interesting to me. Can be useful for making a dashboard, for example.
And I found Apache Isis one of the free and well-known frameworks for that.
Anybody has used it or has any idea regarding it?
btw, I renamed topic to “Master server design” as I thought it is more relevant.
Or can/should I do all those stuff with REST and an in game dashboard (made with Lemur Gui for example) and not use browser?
Personally I’d go for REST as your data API - that way you can represent your data however you like - in-game, on a website, wherever, because ultimately it’s just JSON. You can even implement authentication for users if you want to.
So your layout would be something like:
api.mygame.com - REST
api.mygame.com/news - NEWS endpoint.
api.mygame.com/profile - PROFILE endpoint.
mygame.com - WEBSITE feeding off the API.
So you could have an API endpoint https://api.mygame.com/news that spat out the 10 latest news articles, and so on. Some endpoints could require authentication - which is a fancy way of sending an API key along with the request. The API key is associated with a USER, so if you had an endpoint https://api.mygame.com/profile it would return any user-specific data, etc… (or 403 forbidden if not logged in).
This way you have a data-driven backend that can be represented in any way at all. It’s really handy when it comes to updating front-end GUIs because the data end doesn’t change.
In addition there’s really no issue at all to incorporating your REST API within your game for updating statistics, in-game purchases or whatever. It’s just a very elegant way of dealing with data over multiple platforms and languages. A unification of sorts.
If we look at jMonkeyStore as an example - anyone could create data from its API - or anything - including a SDK.
https://store.jmonkeyengine.org/api/page/top/ - displays the top assets
https://store.jmonkeyengine.org/api/page/38308161-c3cf-4e23-8754-528ca8387c11 - Minie Physics Library
It’s all just JSON that can be integrated anywhere.
This thing requires to deeply understand idea to use it efficiently and it requires to design your whole application in particular way. IMO such things are viable only in enterprise sector.
As I see, what you want are web services (RESTful or not - that’s matter of taste).
Spring MVC approaches to development of web services as it is a private case of MVC. You write POJO (“M”) that describe data you want to transfer between client and server, you write controller - annotated class that calls database and returns POJOs (“C”), but “V”(presentation) part of work is done by fully-automatic JSON [de]serializer.
That’s easy to implement and that doesn’t limit you in other aspects.
As was recommended, spring would be something to look into. Their vault server is crazy good. They have both restful and reactive programming. They have a lot of options for pairing to databases built right into their servers.
Yeah, for me, if I had my choice of anything for the backend it would be spring-boot talking to mongoDB. I don’t know what the commercial licensing looks like for mongo these days but man it’s just a beautiful database for writing RESTful services (JSON natively… even the query language is json).
And while I often curse some of the hidden magic in spring-boot when things aren’t working right, it really is almost just the right amount of magic. And there is a certain intuitive logic about it that you develop over time.
For the http rest client I am using Retrofit with rxjava adapter to be reactive. For server I am using spring webflux but I haven’t decided completely if I will stay with it. Need to search for alternatives and make sure it is the right fit for me.