« Back to Blog

Magic in the Browser: an Introduction

Posted by Matt Soukup at 12/23/2011, 07:59 PM CST

After graduating in Spring 2009, freed from a school workload, transitioning into the working world, and fiery on browser technologies, I began work on my most ambitious project to date: bringing the card game, Magic: the Gathering, to the browser. Experiences with Apprentice and Magic Workstation led me to desire a system that required no installations, no manual updates, and an improved interface. Even wizards Magic Online was a desktop application with a sluggish, unwieldy interface. The browser was the natural progression for magic.

I was on a serious JavaScript kick (story of my life) and YUI version 3 was just starting to pick up steam. YUI 3 really is a thing of beauty. It and Doug Crockford are the reason I have an insatiable obsession with JavaScript.) This project would be my chance at learning sweet new technologies, gaining relevant experience, and contributing a to the community.

I went in a bit blindly in terms of how I was going to accomplish the “push” requirement. Normally, browsers initiate a request and then receive a response. With MITB, the browser would be required to receive “responses” without first requesting. I started really naively, merely polling the server for new changes. This is very wasteful and inefficient. Later, I learned about Comet. This uses an approach called Long Polling, which keeps a request alive until the server is ready to return a response. After the server returns, another request is made and the process repeats. It’s like naive polling, but every request carries some useful data. It allows chat rooms and game transactions!

It’s been 2 and a half years, and progress has been steady. But just last week, I was able to play a “game” of Mono Red versus Illusions in the browser. During my Christmas break, I plan to do some major damage and turn this thing into a reality. More to come.

Loading Comments...

Write Comment