         context.share '__local', context.socket, (data) ->
           context.key = data.key
 
-      for name, h of ws_handlers
-        do (name, h) ->
-          context.socket.on name, (data) ->
+      for {message,action} in ws_handlers
+        do (message, action) ->
+          context.socket.on message, (data) ->
             ctx =
               app: app
               socket: context.socket

    context = {}

    # Storage for the functions provided by the user.
    ws_handlers = {}
    helpers = {}

    apply_helpers = (ctx) ->

        helpers[k] = v

    context.on = (obj) ->
      for message, action  of obj
        ws_handlers.push {message,action}

    context.connect = ->
      context.socket = io.connect.apply io, arguments
