Monthly Archives: February 2012

Firebase from Scratch, pt IV: Games, Services and Tournaments

In a series of posts we’ll do “Firebase From Scratch”, an introduction to Firebase and its concepts and ideas. Hopefully, reading this series will give you a firm grasp of what Firebase is and what it can do.

When it comes to the server code in Firebase, we divide it into three different things, three different artifacts which all have different responsibilities. In the last episode (see “A Maven Interlude“) we kind of skipped past them, but let’s take a closer look shall we?

By |Wednesday, February 29, 2012|firebase|Comments Off on Firebase from Scratch, pt IV: Games, Services and Tournaments

Firebase from Scratch, pt III: A Maven Interlude

In a series of posts we’ll do “Firebase From Scratch”, an introduction to Firebase and its concepts and ideas. Hopefully, reading this series will give you a firm grasp of what Firebase is and what it can do.

Actually, I lied in the last section: We won’t talk about the server game implementation here. Instead we’ll take a quick peak at Maven and how Firebase uses it. If you plan to roll your own using Ant or other tools, this is probably good for you to know anyway.

By |Thursday, February 23, 2012|firebase|1 Comment

How-To Use Cubeia Firebase RNG Service

So, the other day we released an RNG service to the wild. It is a Marsenne Twister implementation with background cycling and discarded draws. It’s fast, secure and possible to drop right into you existing Firebase projects. Here’s how:

First, you need to add the service JAR into your projects dependencies in order to use it. Here’s how it looks in Maven:

<dependency>
  <groupId>com.cubeia.firebase.service</groupId>
  <artifactId>mt-random</artifactId>
  <version>1.0</version>
  <type>jar</type>
  <scope>provided</scope>
</dependency>

Note that we add it as “provided” as it will be included in the service when we’re deployed, so we don’t need to include it into our other dependencies. Generally it’s a good pattern to try not to duplicate classes that are included in services as you open up a can of class loading problems if you do.

Having done this, what you need in order to get hold of an actual Random object to use, is the Firebase service registry. This is available in, for example, the Game context which you get on the “init” method. If we have the game context we can do a method like this:

private Random getRandom() {
  Class<RandomService> key = RandomService.class;
  ServiceRegistry registry = gameContext.getServices(); // needs context
  RandomService randomService = registry.getServiceInstance(key); // get service
  return randomService.getSystemDefaultRandom(); // get random
}

Now you’re ready to roll! You could assign the random to an instance field, but make sure you don’t do it in the game state as the Random is not serialize at the moment, and it will result in an ugly exception if you try it.

Here’s one more trick for you: if you want to use “mvn firebase:run” in you project (have a look here for more details on that), you need to add another dependency. The Firebase Maven plugin needs to know about the actual service archive in order to get your dependencies right, so also add the following to your dependencies:

<dependency>
  <groupId>com.cubeia.firebase.service</groupId>
  <artifactId>mt-random</artifactId>
  <version>1.0</version>
  <type>firebase-sar</type>
  <scope>provided</scope>
</dependency>

By default, all Firebase artifact such as the one above, which are in the scope “provided” will be included in the deploy folder when you run Firebase via Maven. If on the other hand, you’re running Firebase from a standard installation, just copy the “mt-random.sar” archive into “game/deploy” and you’re done!

By |Thursday, February 23, 2012|firebase, java|Comments Off on How-To Use Cubeia Firebase RNG Service

WebSocket Performance

We’re closing in on Firebase 1.8 and the question everyone want to know the answer to: is it smoking? is it hot? And now we have an answer, read on for you performance test fix: Firebase 1.8 Web Socket Performance.

By |Tuesday, February 7, 2012|firebase|Comments Off on WebSocket Performance