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.
Java already have âconnect to a web siteâ stuff built in. You can get fancier but the basics are already there.
As for REST, things like spring-boot make that super simple also. Annotate your methods with RequestMapping annotations, build it with the spring boot plugin, drop it in a web container.
All of these things are 1000x simpler than wrestling with spider monkey just to get some transactional information.
Edit: and most of the time you can test the REST calls directly from your browser. Either with direct URLs for GET calls or with REST plugins for anything else.
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?
Edit:
btw, I renamed topic to âMaster server designâ as I thought it is more relevant.
Edit2:
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.
After you learn rest and reactive programming, use baledung, reactive/restful programming, web flux, in searches and you will find huge amount of data,
This is a complete rest web server with tutorials,
Follow the link at bottom for github repo.
The spring site is where to start though.
Edit: Once you learn the reactive and restful way to program, you can drag the baledung example into the present. Great learning tool.
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.
Did a brief look into Retrofit and it sounds promising, itâs similar to regular RMI calls.
Regarding the reactive part, I think regular Spring MVC REST + async calls from the client would be enough for my needs, but I might consider it in the future if a need comes.