Monthly Archives: January 2012

Node.Js: Links, News And Resources (5)

Previous Post
Next Post

These days, I was working with Node.js and Social Gaming. There is more support for Windows (now we have npm) and for Azure. My new links:

Case study: How & why to build a consumer app with Node.js

shinuza / node-cc-module-boilerplate
A C++ module boilerplate for Node.js

Building native modules for nodeJs 0.6+ with visual studio

tjanczuk / iisnode
Hosting node.js applications in IIS on Windows

WindowsAzure / azure-sdk-for-node
Windows Azure SDK for Node.js
This project provides a set of Node.js packages that make it easy to access the Windows Azure storage and queue services

Accessing Azure Role Environment information from NodeJS

Running wheat git-based blog engine on Windows Azure

Windows Azure Startup task to run npm install to avoid deploying node modules

KABA-CCEAC / nodeEventStore
EventStore Implementation in node.js

I/O Completion Ports
I/O completion ports provide an efficient threading model for processing multiple asynchronous I/O requests on a multiprocessor system. When a process creates an I/O completion port, the system creates an associated queue object for requests whose sole purpose is to service these requests. Processes that handle many concurrent asynchronous I/O requests can do so more quickly and efficiently by using I/O completion ports in conjunction with a pre-allocated thread pool than by creating threads at the time they receive an I/O request.

Leveraging Node.js’ libuv in Windows Azure

Getting the samples to work on the Azure Node.js SDK

Write Logs for Machines, use JSON

thejh / node-forum
You know, a forum. In nodejs.

Microsoft Windows Azure PaaS Gets Node.js Update

scriby / asyncblock
A simple and powerful abstraction of node-fibers

Azure On GitHub

Building Hypermedia APIs with HTML5 and Node

Pollenware / comb
Framework for node that provides a one stop shop for frequently needed utilities (OO, collections, logging, string and date formatting, proxy, flow control, date management)

Real Time Editing with Sockets, Node and Redis

28c3: Effective Denial of Service attacks against web application platforms

Ryan Dahl and software complexity

dreamerslab / thunder
A lighting fast template parser for node.js

Control Flow in Node

Control Flow in Node Part II

Control Flow in Node Part III

substack / node-bigint
Arithmetic on big integers using libgmp

caolan / nodeunit
Easy unit testing in node.js and the browser, based on the assert module.

cloudkick / whiskey
A powerful test runner for NodeJS applications.

c9 / kernel
A simple async template language similair to dustjs and mustache

Dux Released
At it’s core dux is a flexible container that accepts drop in functionality that can be executed from a common command line interface. Adding new commands or extending others is straight forward and simple.

caolan / async
Async utilities for node and the browser

RailwayJS – MVC framework
Create NodeJS web apps faster with more energy, using RailwayJS

Ryan Dahl – History of Node.js
What does he drink 😉

Testing / Spec Frameworks

Node Modules

Search NPM packages

observing / eventreactor
EventEmitters on a syntax suger rush

Debugging native node modules loading failure on windows

The Switch: Python to Node.js

Welcome Nodesters!
There are many avenues to get help with hosting or deploying your node.js applications to Nodester.

apla / workflow.nodejs
Workflow processing for node.js
Every application is based on series of workflows. if your workflow is written in a program code, you have a problem. people don’t want to screw up, but they do. workflow.nodejs is an abstract async processing framework for describing workflows in simple configuration.

What’s new in Windows Azure
Seeking greater relevance and functionality, Microsoft adds a free trial and more open source support

What are the disadvantages of using Node.js?
@zef: “I like Javascript and node.js, but there’s one disadvantage: its asynchronous programming model…
…Until I used Python for a server-side project and remembered how much simpler the synchronous programming style is. How cleaner your code looks. I suppose I had the Stockhold syndrom for a while there.”

The Pass Pattern

Node.JS in Windows Azure
by @ntotten

Transform your IIS into a real-time pub/sub engine with Faye-Node
Faye is a simple Http Pub/Sub server initially implemented by John Coglan in Ruby, and also later ported by himself to Node.js. The version for Node.js implements the Bayeux protocol, which at first glace, many of us known as http long polling.
This project just represents another alternative to Socket.IO, which also works for client applications that are not necessarily implemented within a web browser.  As many http pub/sub engines out there, Faye also uses the idea of channels for routing messages, and it ships with two message repositories out of the box, a repository that runs in memory and a repository that stores the messages in REDIS.

Azure price cuts, bigger databases, now with node.js and MongoDB support, Hadoop on its way

Node js Book Shelf

substack / node-browserify
Make node-style require() work in the browser, as if by magic!

Improved Developer Experience, Interoperability, and Scalability on Windows Azure

Node.js Developer Center

Node.js core contributor explains why it’s ready for the big time (video)

Deploying Node.js Applications to Windows Azure via Blobs or Git Sync
by @smarx via @asehmi

ajaxorg / node-github
node library to access the GitHub API

pksunkara / octonode
github api v3 in nodejs

My Links

More links and examples are coming.

Keep tuned!

Angel “Java” Lopez

Social Games Programming (Part 8) Adding Node.Js

Previous post

In the previous post, we explored the game processing in the current Windows Azure Toolkit for Social Gaming. Now, it’s time to add Node.js as game server, in our Tic Tac Toe simple game.

All the Game Service client code is game agnostic. And it can be changed to use another services. In this post, I will change the play move processing to be directed to a Node.js instance.

You need to download the node folder from my GitHub:

Then, follow these steps:

1 – Download and setup the Windows Azure Toolkit for Social Gaming version 1.1.1, from:

1 – Install Node.js for Windows, from

2 – Change to the server folder, and execute this command line:

npm install

The library is downloaded and installed in a node_modules subfolder:

This is the folder tree:

3 – Start the node.js server:

node gameex.js

The server starts to listen:

4 – Copy the client folder to your SocialGaming.Web project folder. Web.config, BaseController.cs, TicTacToeController.cs files will be replaced. New files will be added: Scripts\game\GameServiceNodeJs.js, Areas\Samples\Views\TicTacToe\NodeJs.cshtml.

5 – Open the solution in Visual Studio 2010 (run as administrator) and add these files to SocialGaming.Web project. The new Game Service for Node.js:

The new TicTacToe view that uses Node.js:

The new action in the replaced TicTacToe controller:

There is a new entry in the web.config file:

The replaced BaseController reads that setting:

6 – Start the application (it should run as to be accepted by the Federated Security running in ACS portal). See the invite URL:

7 – Browse to /Samples/TicTacToe/NodeJs:

8 – The client connects with the Node.js game server:

My browser doesn’t understand the WebSocket version implemented in the server library. Then, fallback to use xhr long polling.

9 – Open a new browser, in a private session, with the URL provided by the step 6

10 – These are the two players. The left one played at top left cell. The right player receives the new move and update its view.

11 – See the server console: the move was received and broadcasted to the game participants:

Nice! Homework: add the Node.js to a worker role (see @ntotten post NodeJS on Windows Azure).

Next topics: explain in detail the server code (it supports client that uses plain TCP sockets instead of, so you can program a client in other platforms, from Silverlight to iPhone to Android).

Keep tuned!

Angel “Java” Lopez

Social Games Programming (Part 7) Game Moves Processing

Previous Post
Next Post

In this post, I want to discuss the game play processing in Tic Tac Toe. It involves many pieces, from Razor view using Javascript to Web Role, to Azure Blob Storage.

These are the javascript files referenced in Tic Tac Toe view (at SocialGame.Web/Areas/Samples/Views/TicTacToe/Index.cshtml):

<script src="@Url.AreaContent("Scripts/jQuery.tmpl.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/knockout-1.2.1.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/game/ServerInterface.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/game/GameService.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/game/UserService.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/game/TicTacToeBoard.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/game/TicTacToeGame.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/game/TicTacToeViewModel.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/game/TicTacToeController.js")" type="text/javascript"></script>

As I wrote in the previous post, ServerInterface, GameService and UserService are game-agnostic components. They could be used in any game. For each new kind of game X, you must implement XBoard, XGame logic, XViewModel and an appropiate XController.

At the end of that view, there is the creation of the game-agnostic services:

var apiURL = "@this.ViewBag.ApiUrl";
var blobURL = "@this.ViewBag.BlobUrl";
var si = new ServerInterface();
var gs = new GameService(apiURL, blobURL, si);
var user = new UserService(apiURL, blobURL, si);

The @this.ViewBag properties are filled in the ASP.NET MVC controller (see BaseController.cs)

The creation of the game controller:

// check for canvas, show an "Upgrade your browser" screen if they don't have it.
var canvas = document.getElementById('board');
if (canvas.getContext == null || canvas.getContext('2d') == null) {
var board = new TicTacToeBoard(canvas);
var game = new TicTacToeGame();
var controller = new TicTacToeController(viewModel, gs, board, game);

But the interesting part is in the controller constructor:

function TicTacToeController(viewModel, gameService, board, game) {
    this.viewModel = viewModel;
    this.gameService = gameService;
    this.board = board; = game;
    this.started = false;
    var controller = this;
    this.board.onMove = function (x, y) { controller.onMove(x, y); };

Notice the this.board.onMove: the controller register itself to process new moves detected by the board component. At its start method, the controller register itself to process game service updates:

        function (queue) { controller.processGameQueue(queue); },
        function (action) { controller.processAction(action); }

Let’s examine the processing of game moves.

1 – The board component detects a click, then it sends a new move to controller (using the onMove callbalk)

2 – The controller sends the new move to game logic, to update state (I omitted the view model in this sequence/graph)

3 – The controller sends the new move to game service.

4 – The game services sends a new command to web role, using the server interface

5 – The Web Role API receives the new command

6 – The command info is appended to the game status blob, at Azure storage

Now, the other client processing:

1 – The game service, using a timer, polls the game status, calling the service interface

2 – The service interface, using JSONP, retrieves the current game status from Azure Blob storage

3 – If a new move is detected, the game service calls a callback function provided by the controller (game service has no reference to controller).

4 – The controller sends the new move to game logic, updating state (I omitted the view state here)

5 – The controller sends the new move to board component, to update the canvas

A key point: the controller knows NOTHING about the service interface, WCF Web API, blob storage. So, you can change the game service to route and detect new moves in other ways. Next post: modify game service to use a Node.js server for game move processing.

Keep tuned!

Angel “Java” Lopez

Content Repository: Links, News and Resources (1)

Recently, I was working on my open source simple content repository, AjCoRe, having nodes and properties, based on the JSR-170 concepts. Now, I’m reading some additional resources: API, concrete implementations, uses cases, etc. This is the list of links I have collected about the topic:

A content repository is a store of digital content with an associated set of data management, search and access methods allowing application-independent access to the content, rather like a digital library, but with the ability to store and modify content in addition to searching and retrieving. Acontent repository thus typically forms the technical underpinning of a content application, like a Content Management System or a Document Management System. It functions as the logical storage facility for content

A content repository exposes amongst other the following facilities:

  • Read/write of content
  • Hierarchy and sort order management
  • Query / search
  • Versioning
  • Access control
  • Import / export
  • Locking
  • Life-cycle management
  • Retention and hold / records management

What is Java Content Repository
The Java Content Repository API (JSR-170) is an attempt to standardize an API that can be used for accessing a content repository. If you’re not familiar with content management systems (CMS) such as Documentum, Vignette, or FileNet, then you must be wondering what a content repository is. Think of a content repository as a generic application "data store" tht can be used for storing both text and binary data (images, word processor documents, PDFs, etc.). One key feature of a content repository is that you don’t have to worry about how the data is actually stored: data could be stored in a RDBMS or a filesystem or as an XML document. In addition to providing services for storing and retrieving your data, most content repositories provide advanced services such as uniform access control, searching, versioning, observation, locking, and more.
Introducing the Java Content Repository API

JCR Primer
The following pages contain a primer on the Java Content Repository specification.
JSR170, the Java Content Repository, constitutes an extremely complex specification. The successor, JCR 2.0 / JSR 283, specification adds even more complexity. However, the JCR REPRESENTS a very generic and object-oriented content repository which touches almost all features known in the space. The content repository is not a full-fledged content management system or a content management API. It is only the small subset of a content repository, a storage engine, which a content management system can be built on top of.

Java Content Repository: The Best Of Both Worlds

Compact Node Type Notation in a Nutshell

Content Management with Apache Jackrabbit

JCR In Action
Content-based Applications with Apache Jackrabbit

Apache Jackrabbit Examples

Introducing the Alfresco Java Content Repository API
This article introduces you to the Alfresco implementation of the Java Content Repository API (aka JCR or JSR-170) by designing and developing a simple WIKI like back-end using both Level 1 and Level 2 JCR features.

Oracle Beehive Java Content Repository

Catch Jackrabbit and the Java Content Repository API

The SharePoint content repository: It’s just a database
SharePoint’s repository — where all its content lives, is indexed, and is version-controlled — isn’t some special data construct. It’s just a database — a SQL Server database, to be specific.

Apache Sling – Bringing Back the Fun
Apache Sling in five bullets points:
– REST based web framework
– Content-driven, using a JCR content repository
– Powered by OSGi
– Scripting inside, multiple languages (JSP, server-side javascript, Scala, etc.)
– Apache Open Source project

Apache Jackrabbit
Apache Jackrabbit is an open source content repository for the Java platform. The Jackrabbit project was started on August 28, 2004, when Day Software licensed an initial implementation of the Java Content Repository API (JCR). Jackrabbit was also used as the reference implementation of JSR-170, specified within the Java Community Process. The project graduated from the Apache Incubator on March 15, 2006, and is now a Top Level Project of the Apache Software Foundation.

Content Repository API for Java

Content repository like JSR-170 in .net?

Open Source Sharepoint Alternative

Eclipse Enterprise Content Repository
Overview of Nuxeo Core

IIOP enabled jackrabbit-jcr-rmi, .NET 2.0 Remoting Layer Implementation, .NET 2.0 Repository Explorer implementation, .NET 2.0 implementation of JSR-170 API

JSR 283: Content Repository for JavaTM Technology API Version 2.0

Why, when, how?

My own work, AjCoRe

My Links

More work on AjCoRe is coming.

Keep tuned!

Angel “Java” Lopez

What is Windows Azure?

Past year, I wrote many blog post about Azure programming. Maybe, you know about cloud computing in general, but not about Azure in particular. Today, thanks to Windows Azure + a pinch of UK published by Eric Nelson (@ericnel), I found this video, that explain in simple terms the key technical pieces of Azure:

For more information about the video, see Steve Marx (@smarx) post:

What is Windows Azure? (a Hand-Drawn Video)

It has an interesting section title: “How I Made It”.

Notice the difference of compute nodes and storage nodes. Both service can be emulated in your local machine, thanks to Azure tools for Visual Studio.

My links about azure:

A post about Azure, games and Node.js is comming.

Keep tuned!

Angel “Java” Lopez

New Month’s Resolutions

In my opinion, using a year for resolutions is too much time. I prefer to have smaller periods for life iteration. One year gives a lot of time for procrastination and lost of focus. My proposal: to have monthly resolution. Yesterday, I wrote about my public not technical resolutions, in Spanish. Now, it’s time to write down a short list of technical resolutions, with public outcomes:

– Implements Id in Nodes in AjCoRe (simple Content Repository)
– Implements Server/Client in AjKeyvs (Key Value Store)
– Start a new version of my PHP simple framework, revamping old one, to publish in my GitHub account
– Publish a simple web server example at my Node.js samples
– Publish a simple HTML5/Canvas game using Node.js as game server (at Node.js samples)
– Continue working on AjLang interpreter, Ruby-like syntax over .NET types and objects
– Continue working on AjLisp in Java
– Play with Clojure REPL
– Start writing AjRools.Expert, rule engine in C#, a la JBoss Drools Expert (it will be published in GitHub account)

I could add some posts about these items, but all them have public repository, so the commits will serve as a proof of advance of this list.

After this first month (January 2012), I will write down a new list, maybe with improvements (better definitions, improved defined outcomes, etc.). Most of these resolutions are centered on studying new things, and practice, practice, practice, practice.

Keep tuned!

Angel “Java” Lopez