Monday, October 29, 2007

Apple and Java 6 - I am not getting a MacBook Pro

I am looking to replace an old laptop and get myself a brand new development machine. At first it seemed a no-brainer:

"I'll just get one of those oh-so pretty MacBook Pros"

My wife has owned an iBook for around 2 years. She even paid the money to update to OSX Tiger, and bough the .Mac yearly subscription for the 3rd time now. So despite a few issues she is clearly quite happy with her Mac and continues to throw money at Apple.
Until recently I thought I'd get an apple as well but I changed my mind very quickly in the light of recent events and after a bit of investigation.

So here is why I will not be getting a Mac:

1. I am a Java developer (one of about 5 million apparently) and there is no Java 6 on OSX, not even in Leopard

That's it.

I guess I could buy the MacBook Pro and run Linux (which I've been running so far on my Toshiba Tecra), but for the money I can get better hardware elsewhere. The value for me is in having a MacBook AND OSX. If OSX is out due to lack of Java support, the deal is off.

I'll not make an actual purchase for about 3 months and perhaps in that time Steve will come to his senses and change the company attitude towards Java developers and users in general. And now BEHOLD as I will conclude this blog with a poem of my own making.

Again old saying seems to hold
That all that glitters is not gold
With OSX less Java 6
I'd lose my job, start turning tricks
Apple needs to listen well
Else I'll end up with a Dell

Monday, October 22, 2007

BattleBlocks released ...

Most excellent news :)

Last night we released BattleBlocks (our Tetris clone) and let me tell you, I've spent lots of time "testing" the game :) Even though I didn't write that one (James O'Connor wrote BattleBlocks for us) it is my all time favorite Cotopia game. It is that much more embarrassing that Tomas beat me twice last night and I didn't get a point on him... awell, maybe next time.

In addition to BattleBlocks we also pushed out new versions of all existing games with additional features so check it out ASAP.

- Forum posts have dates attached
- Better in game chat screen
- Can send SMS invites to friends straight from main menu
- Blocking of empty chat messages

Just go to http://cotopia.mobi on your phone, download all the games, and let us know what you think. Many of the changes in this release were based on community comments.

Wednesday, October 17, 2007

11000 players

We celebrate!
So far we have 11000 players. I think that's great, but we want more. If you know about any portal, which could add our games to their catalog, please let us know.

With a little luck, we will be able to announce partnership with a major portal from India soon, so stay tuned.

Other info:
You can read our blog directly from your phone at the address http://cotopia.wirenode.mobi
You can make your own mobile blog and portal at www.wirenode.com. It's very easy, try it!

Saturday, October 13, 2007

EJB3 TimerService spec needs fixing

We've gotten many complaints about our scoring bug: people just leave the game (which they are presumably losing) time-out and do NOT lose any points ... how can this be?

It shouldn't happen and the issue has been fixed.

The error was in a little code of "silly logic" which would create clearner timers but then also kill them before they got a chance to run, the issue was thread related (as usual). How I fixed it?
(Read on if you care about the technical details of the bug in our Java EE system)

Using TimerService we have set up two timers in the EJB3 session beans that manage game creation (matching opponents etc.) and game play (including scoring). These timers execute the @Timeout methods every few seconds to make sure people get their points and there are no stale old games sitting around:


@Stateless
public class GameManagerBean implements GameManagerRemote, GameManagerLocal {

   @Timeout
   private void cleanUnmatchedGames(Timer t) {
     ... clean unmatched abandoned games
   }

   public void startGameCleanerTimer() {
     this.stopGameCleanerTimer();
     this.timerService.createTimer(PERIOD_MS, PERIOD_MS, GAME_TIMER_ID);
   }

   public void stopGameCleanerTimer() {
     for (Iterator it = this.timerService.getTimers().iterator(); it.hasNext();) {
       Timer timer = (Timer) it.next();
       if (timer.getInfo().equals(GAME_TIMER_ID)) {
         timer.cancel();
       }
     }
   }

}

@Stateless
public class PlayManagerBean implements PlayManagerRemote, PlayManagerLocal {

   @Timeout
   private void cleanTimedOutGames(Timer t) {
     ... clean games where one player timed-out or left
   }

   public void startPlayCleanerTimer() {
     this.stopGameCleanerTimer();
     this.timerService.createTimer(PERIOD_MS, PERIOD_MS, PLAY_TIMER_ID);
   }

   public void stopPlayCleanerTimer() {
     for (Iterator it = this.timerService.getTimers().iterator(); it.hasNext();) {
       Timer timer = (Timer) it.next();
       if (timer.getInfo().equals(PLAY_TIMER_ID)) {
         timer.cancel();
       }
     }
   }

}


To be certain that the above @Timeout methods are called by a single timer at regular intervals we have to make sure that one and only one timer of each kind is alive at any one time. Timers are persistent (survive server crash or shutdown) which can be nice but it can also be a pain since it means that if you start a timer every-time your server starts you'll be accumulating them. To make sure that we create timers once per server startup and delete them on server shutdown I put the code into servlet life-cycle methods.


public class MobileServiceServlet extends HttpServlet {
   public void init() throws ServletException {
     this.gameManagerBean.startGameCleanerTimer();
     this.playManagerBean.startPlayCleanerTimer();
   }

   public void destroy() {
     this.gameManagerBean.stopGameCleanerTimer();
     this.playManagerBean.stopPlayCleanerTimer();
   }
}


You may have noticed that to ensure that only one timer of a kind is alive at a time the startGameCleanerTimer() and startPlayCleanerTimer()methods also delete any old timers which may be around due to server crash. Just to be on a safe side.

All these code gymnastics just to make sure that we aren't starting multiple timers, I hope that the next Java EE spec will include some "on deployment" related features so that this is no longer necessary.

Sunday, October 07, 2007

Scoring fixed

As some of you may have already noticed, we've deployed a new version of Cotopia server, this means that once you accept a game you cannot chicken out without losing or gaining points :)
I am sure that there will be quite a few people happy about this. Soon to follow will be the new MIDlets so keep an eye out for further announcements.

Monday, October 01, 2007

A quick update

Just like I promised in a previous blog entry, I've been working on BattleBlocks and I have a stable version ready .. well stable enough not to break the emulator :) So the time-frame we're looking at for releasing the new version of Cotopia (including all the promised fixes) is about 2 weeks from today.

I am pretty happy about the new release because it seems that many of our naughtier players have been abusing the scoring bug. You know who you are .. rest assured that a fix is coming and the points gained by cheating will be quickly lost if you don't have the skill to back them up :)

In semi-related news, we may be getting more players from India in the near future, I hear a lot of good chess players come from there so brace your selves ...