[SOLVED] What does the new HostedServices class do?

Hi monkeys! Today I was reading the list of new features of the JME 3.1, and I noticed the new HostedServices class, which is related to the networking. I got curious, so I decided to look for it in the javadoc and the forums, but I couldn’t find anything, except a thread that asks for examples of usage. The only info that I know is that is “Essentially like AppStates, but independent of jME3 Application infrastructure”.

So, can someone explain me what is this class used for, and how to use it?


The best examples are probably the ones included in SpiderMonkey. I know I’ve been remiss documenting this new stuff.

Basically, you can register a service that has a lifecycle that matches the connection, can access other services, and can get notified whenever there is a new connection. Similarly there are client-side services which do the same thing on the client… and moreover those are initialized in such a way that you can be sure the server has already been notified of the connection and so on.

I got tired of writing the same code over and over so I standardized it. Take a look at the RPC related services for a pretty basic example.

Edit: P.S.: I also have an RMI client/server service that I havent’ checked in. It’s built on top of the RPC services and can show how to layer services like that. Not sure when I will polish it and publish it as I hoped to have a little more ‘burn in’ time to validate before committing it. Might have to let the community do that.

Thanks for the explanation @pspeed! Another problem solved xD