Master server design

new URL(“myserver/restMethod”).getContent()

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.


If you need something more than the basic URL fetching @pspeed mentioned, the JDK has had a built in HTTP client built in since JDK 11:


Thanks so much, guys. Your posts were very informative. I appreciate your help. :slightly_smiling_face:

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: - REST - NEWS endpoint. - PROFILE endpoint. - WEBSITE feeding off the API.

So you could have an API endpoint 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 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. - displays the top assets - Minie Physics Library

It’s all just JSON that can be integrated anywhere.


Ah, I see. It’s clear now. thank you so much @jayfella :slightly_smiling_face:

1 Like

We went through a similar conversation with @mitm a while back. It might be interesting reading.

[SOLVED] World server design questions simethereal

1 Like

Thanks, going to read that. now that I have a clear understanding of REST, it should be easy for me to understand what is going on there :slightly_smiling_face:


btw, this was one of the things that I was completely in dark thinking how should I do, but now it totally makes sense.
Again appreciate your help.

1 Like

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.

Not bad example: Getting Started | Building a RESTful Web Service

1 Like

Hey @ali,

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.

To get you going,
This leads you into the abyss. It connects to everything spring.

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.

1 Like

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.


Spring is so flexible. So many different ways to do whatever you want.

Edit: Thanks for showing me the way. I got lost in it for 8 months.


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.

Thanks :slightly_smiling_face:

Check out AsyncConfigurer.

1 Like

Thanks, @mitm :slightly_smiling_face:

Yeah, that is what I like about retrofit, you just write an interface like the controller of the server and call it like it was RMI. you don’t need to implement anything either. If you don’t like RxJava, there are other adapters. I believe you can use Promises as well if that is more your thing.


Hey guys

I am back with another question,

Is it a good idea to use Server-Sent Events (SSE) with my RESTful master server for cases I need realtime communication and to prevent Http request polling. (for example every 10 seconds)

For example when a party invitation request or friend request is made, or when the master server sends a necessary message or showing the realtime status of friends (offline/online/in-game)…

I am not familiar with SSE yet, but I read it is a cheaper solution than WebSocket, and that is an HTTP standard that handles a unidirectional event stream and receives updates whenever the server emits data. (Client can just receive data from server but can not send anything)

Or you think it’s a bad smell?

I am interested to hear your opinion as well.

My personal opinion is that if I wanted to maintain a constant connection - such as chat - or anything that requires real-time updates (over http) I would use a web socket.

If time wasn’t a priority - e.g. updating a forum new post - I would just poll. Every 10, 15, 20 seconds would be perfectly fine for that situation.

Sockets are pretty light-weight and allow you to decide when to send something either way. Polling only allows sending on request.

It depends entirely on how you want it, really. Any mechanism is going to require some kind of throttling.

1 Like

Reading over it a few times, it sounds like you’re in-game when this is happening.

If this is the case - you want to connect to a primary server using tcp, but not necessarily http. You would create a protocol - such as a handshake agreement and data bundles (request/send) and handle it like a regular socket connection. There’s no need for http unless you want this data publicly available for others to see on a website.

1 Like

No, we are not in-game yet. The player is not yet connected to the game. Suppose that he is in the “Social” tab and can see a list of all his friends and their status and so on.

All the scenarios I am talking about are about communicating with the master server.

regarding chat, it is an in-game feature and will already be handled by JME Networking in realtime.

10, 15 seconds should be fine for my needs in case polling will not cause trouble off-course.