Hemlock

Build multi-user, real-time web applications.

Download

Hemlock Initial Release

Blog

Hemlock JS

by Ron

When building the original Hemlock framework, we chose ActionScript because it has widespread browser support, and lets us open a real socket connection. However, one of the biggest complaints we received was, of course, that we used ActionScript.

If you've been watching the progress of our flagship Hemlock product, Picklive (formerly known as Football3s), you've already heard the news:

Hemlock will now be developed primarily in JavaScript. No ActionScript/Flash necessary.

The revamped Picklive interface is written with the new Hemlock JS framework. If the browser supports Flash, Hemlock uses an invisible, pre-compiled Flash element called HemlockPixel to open a socket connection with the XMPP server. If Flash is unavailable, Hemlock falls back to BOSH and long polling via JavaScript (thanks to the Strophe project). Your app's business logic doesn't need to change based on the connection method: Hemlock detects each browser's capabilities, and switches connection methods automatically.

When Hemlock JS is production-ready, here's how your JavaScript app will send a data payload to everyone in the room:

app.sendData('game_move', {
  locFrom:  [10, 10],
  locTo:    [20, 20]
});

Here's how you'll receive a data payload:

// Adds a handler for incoming data
app.receiveData('game_move', function(elem, data){
  var from = elem.getAttribute('from');
  console.log(from + ' moved from ' +
    data.locFrom + ' to ' + data.locTo);
});

And here's how you'll handle arbitrary stanzas, like <presence/>s for keeping track of users in the room:

app.receiveElement({
  name:     'presence',
  callback: function(elem, data){
    var from = elem.getAttribute('from'),
        type = elem.getAttribute('type');
    switch(type){
      case 'error':
        /* ... */ break;
      case 'unavailable':
        console.log(from + ' disconnected'); break;
      default:
        console.log(from + ' joined the room'); break;
    }
  }
});

Since there are so many great tools for building user interfaces with JavaScript, Hemlock JS won't include interface helpers like in the ActionScript codebase. Hemlock provides the connection mechanisms; your app has full control over the rest.

Picklive has already made successful use of Hemlock on the iPad and iPhone with BOSH and long polling via JavaScript. While polling is sufficient for now, we intend to add support for HTML5's WebSocket API, which browser vendors are rushing to integrate.

With this new direction in mind, let's rethink the first Hemlock roadmap, posted back in September 2009. Hemlock 0.2 will be a production-ready version of Hemlock JS. It'll include BOSH support as planned, as well as a little example app. Down the road, we plan to add support for the WebSocket API. In browsers that don't yet support this API, Hemlock will fall back to a socket connection via Flash; failing that, Hemlock will fall back to BOSH via JS.

If you're interested in seeing our progress, or want to contribute to a real-time open source project, check out Hemlock on GitHub or Google Groups.

World's first Hemlock job

by Utku

Want to create social games using Hemlock and redefine what's possible on the web? We are looking for a developer to do just that.

Not only will you be working on developing exciting web properties like Football3s, but your work will also feed back in to Hemlock framework and help others developing real-time web apps.

The details are over here.

Get in touch!

Bamzooki

by Utku

Sometimes TechCrunch breaks your story before you get to write about it. Us? We have no excuse, we're 5 months late!

When we showed cBBC - that's the children programming arm of the BBC - Hemlock, they were really excited and commissioned us at Mint Digital to build a trumps style game for a show called Bamzooki.

Bamzooki is a 'mixed reality' television gameshow. Using a downloadable toolkit, users create 'Zooks', autonomous creatures with unique features. The best Zooks get featured on the TV show.

In the Hemlock Bamzooki game, each Zook has a card with its stats. Choose a stat and if it's the highest, you win all the cards in that round!

BBC is using the Bamzooki card game as an internal showcase for Hemlock. Adam Khwaja, a producer at the BBC said: "The appeal comes from the casual approach to gameplay that Hemlock allows; being able to dive straight into a realtime multiplayer game without having to register or face a steep learning curve".

The Bamzooki card game was the first Hemlock app we built for a client. We are extremely pleased that first client was the BBC. We just wish we told you about it sooner!

The Hemlock Roadmap

by Ron

The real-time web movement is picking up momentum, and we're thrilled to see that more and more developers are building their own Hemlock apps!

As you can tell from the activity in our GitHub repository and our Google group, we've busily been making refinements based on feedback from developers. We're also working toward features that will make it easier to get your own real-time web apps running.

Here's the roadmap so far:

0.1.x: Maintenance updates

We plan to make a series of small updates, not necessarily in this order:

  • Better testing support
  • Info on deploying to production sites
  • A smaller example app for easier understanding

0.2: BOSH support

If the user is stuck behind a corporate firewall, the browser might not be able to maintain a socket connection with the XMPP server. The BOSH transport protocol solves this by instead streaming XMPP data over HTTP.

0.3: Generators for creating template apps

With a few basic command-line commands, you'll be able to generate the files and folders you need—with a lot of ActionScript already written for you. If you're interested in our progress here, check out the "generators" branch on GitHub.

Along the way, we're continually working toward complete documentation for v1.0, as well as better Windows support. If you're developing on Windows, we'd love to hear from you. Others are discussing this in our Google group thread, "Hemlock on Windows".

What other features are you looking for? Let us know in the Google group or on Github.

Ron

Fancy a draw? Hemlock in action.

by Utku

DrawingDemo, featuring DrawingWidget

A question we often get asked is "Where can I see a Hemlock app in action?".

Well, Football3s is great for that, but football (soccer) matches run to a schedule and you can't always play.

To solve this, we decided to host a public version of DrawingWidget. Five people at a time will be able to go in to a room and draw at the same time on the same canvas.

It's a simple but effective demo of Hemlock, and should hopefully spur your creativity for thinking about your own Hemlock apps.

A couple of things:

  • It's a tech demo, so be gentle if not everything goes right!
  • You only see the drawings done after you joined the room.

You can play now! Enjoy and see you in the drawing rooms!

Hemlock begins: The 0.1 release

by Ron

ON / OFF

(Original photo by Andrew Huff)

Start the party—Hemlock 0.1 is ready for download! We just flipped the switch on our GitHub repository, so you can now peruse the Hemlock source code, download it, and try it out.

Hemlock includes an example app called DrawingDemoContainer. This shows off two of the starter HemlockWidgets: a basic chatroom, and a multi-user canvas for drawing pictures. Either of these can be reused, modified, and skinned across Hemlock apps.

You can learn more about Hemlock and the setup process in our Learn section. We're cooking up many improvements to ease the development process, and we'll post a roadmap soon so you'll know what to expect in upcoming releases.

What do you want to see in the next version? Let us know via our GitHub issue tracker, or Twitter @ronalddevera.

A Hemlock app, in action.

by Utku

Football3s

Football3s is our flagship Hemlock app. It's a real-time fantasy football game that you play along to a live match on the TV, or radio. Today, we will be playing along to England v Kazakhstan and kick-off is at 4PM BST.

Just go to Football3s to get started. You can follow the action either on your TV on Setanta Sports 1 or BBC Radio Five Live, which you can listen to online.

Hope to see you during the game!

Utku

Understanding Hemlock

by Ron

I had a recent conversation in which friend "C" asked what made Hemlock better than Ajax:

C: So basically AJAX is like this:
C: How about now? how about now? how about now?
C: ...Really?
Ron: Yup.
C: That's so funny.
C: The web's current top notch technology is like an impatient and really annoying child
Ron: Yeah
Ron: So the server says, "Not yet. Not yet. Not yet. Wait... not yet. Wait....... not yet."
Ron: This is why Hemlock's like, "Okay, SHUT UP. I'll tell you when."

Ajax is like an annoying child, nervously polling the server in hopes of something new. An Ajax app might vary the polling frequency or use long polling, but it still means opening a new connection every time the browser wants to check for new data. Opening a new connection means network latency and network latency is the enemy of real-time web apps.

Hemlock takes a different approach: The browser opens a single connection to the server. Whenever there's new data, the server pushes it to the browser via that one connection—no need for the browser to keep polling, and no need for additional connections. That means noticeably less network latency giving you ultra-fast, real-time data transfers among your users.

The ingredients

Hemlock builds upon two technologies:

  • XMPP: Also known as Jabber, XMPP is commonly used to enable chatrooms, like Gtalk or Facebook Chat. However, instead of just sending text, Hemlock lets you send all kinds of data at the speed of instant messaging. Even better, XMPP is designed to scale up and send data to many people at once, so you can push that data to multiple people in real-time.

  • Flash: With Flash, Hemlock can open a single persistent connection between the browser and the server. You'll also be able to build beautiful, responsive user interfaces that send and receive network data very easily.

When writing Hemlock code, you'll primarily be writing ActionScript (specifically, AS3), which compiles into a Flash SWF file.

Imagine what we can do with this. We can create a blank, Flash-based canvas on which someone draws a picture. Then, using XMPP, we can let other people join that same canvas (like joining a group chatroom). Whenever someone draws on that canvas, that data is sent to everyone else in the room, and everyone sees the same drawing. In real-time.

We've built this for you. It's called DrawingWidget, and it'll be part of the upcoming code release.

Sending and receiving data

Here's how you send data with Hemlock:

// GameEvent.CLICK is a constant string:
widget.sendDataMessage(GameEvent.CLICK, {
    mouseX: 314,
    mouseY: 159
});

And here's how you receive data with Hemlock:

widget.registerListener(container, GameEvent.CLICK, onGameClick);
private function onGameClick(event:GameEvent):void{
    Logger.debug('Incoming click: '
        + event.options.mouseX + ' x '
        + event.options.mouseY);
}

Simple.

In this micro-example, GameEvent.CLICK is a string that tells what type of data is being sent. This way, the recipient knows how to process the incoming data payload.

How to build a Hemlock app

A Hemlock app consists of two types of components, a HemlockContainer and some HemlockWidgets.

HemlockContainer

The HemlockContainer is the heart of the Hemlock app, and is the ActionScript compiler's starting point. The container is responsible for maintaining the app's models: it tracks the app's state, such as the list of users playing a game, and how many points each user has. The container also holds a collection of HemlockWidgets, described below.

HemlockWidget

While the container maintains the app's model data, the HemlockWidget maintains the app's views: creating the user interface and handling user input, such as chat messages and mouse clicks. The widgets packaged with Hemlock are designed to plug into any Hemlock app. For instance, we'll provide ChatroomWidget, which lets users send text-based messages to each other, and DrawingWidget, which lets users draw pictures on a single canvas in real-time.

Next steps

We're getting close to releasing some code for you to play with, including more setup notes and an example app. I'm looking forward to seeing what you come up with!

Tell me what you think @ronalddevera!

Why no source yet? An explanation

by Cameron

We've gotten a good deal of stick for releasing an open source project, without the (ahem) source. First of all, we unreservedly acknowledge the absurdity of such an action, and an explanation is in order. It comes down to licensing.

Hemlock is currently (but not inherently) tied to XIFF which is released under the LGPL, and we'd like, if possible, to release Hemlock under the less restrictive MIT license. In order to do this we need to segregate the two components of the project before we release it, which is what we are hard at work doing. We do not expect this to represent a huge problem, more a matter of days than weeks, but it's the one sort of problem you can't really "go back and fix later", so we must solve it prior to release.

We're encouraged and surprised by all the interest, and I promise that we'll have source up as soon as we can. It'll be a bit rough around the edges, but based on your feedback, it's clear that you'd rather have rough around the edges than nothing at all.

24 hours later

by Utku

It all started with a tweet yesterday afternoon.

Twitter / Mint Digital: Introducing Hemlock, the n ...

24 hours later, we had; 13,000 page views, countless tweets, made it on to top links on Delicious, front page of Hacker News and got covered on a few blogs too. Here are some of our favourite comments:

"Seriously exciting framework for building realtime web apps: http://hemlock-kills.com" Ryan Carson

"Now this http://hemlock-kills.com/ is a fucking awesome project site name. " Zed Shaw

"I used to think "git" was the worst name in software, but now I have revised my opinion." frossie on news.ycombinator

"Google Wave? It's a bit like Hemlock!" @claire_w, in the pub.

We're absolutely thrilled with the interest shown in Hemlock. Thank you. Our developers also seem suitably encouraged, if the rate of commits to the Hemlock git repo are anything to go by! They will start to share code examples and technical insights later on.

Thank you all for your interest once again and do keep an eye out on this blog for updates on all things Hemlock.

Utku

The road to Hemlock

by Utku

hrd

In late 2008, Andy, Noam and Tim had an idea for a football game that would combine fantasy football with bingo-like dynamics. Around the same time, Cameron was convinced the future of the web was going to be 'real-time'. On one fateful Sunday brunch, they decided to combine their thinking and create a real-time fantasy football game. But first, they were going to need some clever technology to drive it. And more toast.

Fast forward to May 2009. That game became Football3s and that technology became Hemlock.

Mint's developers have been working on Hemlock for the past 6 months. We've had fun developing the framework and we've built some pretty cool apps. But now is the time to get it into shape for public release.

The decision to release Hemlock as an open source framework was a no-brainer. We believe real time interactions will be what defines the near-future web. So, it's exponentially more exciting to share enabling technology than keep the goodness to ourselves.

So, when are we going to release Hemlock? As soon as we can help it. The Hemlock team are busy refactoring, tidying and documenting. As soon as it is in state where you would curse us only occasionally, we'll be good to go!

In the meantime, join us for regular updates and tech talk from the team, an insight into launching an open source framework and light banter on the road to Hemlock.

See you along the road!

Utku

Subscribe

News

  • Coming soon: Support for 100% JS environments

    Yes, that includes the iPhone and iPad.

    GitHub branch