The Denby command line… what-the-what?!

Yes, Denby has a command line. No, you don’t have to use it. But it’s incredibly quick and convenient for development… which is still ultimately a win for users who don’t (want or need to) care about it!

The client side of Denby is split into two pieces: the core communications module, which provides a programming interface to the Denby server; and the user interface module, which howitzers the awesome straight at your face.

As you can tell from previous posts, my focus right now is a multi-column, “death star console” user interface, but I do plan for more (single-column, mobile, etc). So in a way, the command line in your browser console is just another user interface profile. 🙂

Now for some technical details.

A set of functions on the server side is exposed to the client via JSON-RPC over the same Socket.IO pipe from which all your streaming tweets arrive. In the optimal case, this is a websocket or flashsocket, so it’s designed for bidirectional chatter.

When you Denby.send(), a JSON-RPC packet with a unique ID is sent to the server, which does whatever you’ve requested and sends back a response with the same ID attached. That way, the client can keep track of requests and responses.

I have tried to make this as seamless as possible, though I’m still cheating a bit. Surely it would be nicer to call, say, Denby.updateStatus() versus Denby.send('updateStatus')? I will eventually get there, but am also striving to get the balance right between getting out of alpha mode, surfacing features and gold-plating the infrastructure. 😉

The example below shows one of the simplest functions, updateStatus(text, [params]), called on the server by Denby.send(method, [arg1], [arg2], [argN], callback). I made it accept an arbitrary number of arguments before the callback just to make things a bit easier. The callback is of course a local function, remembered by the JSON-RPC client and called when the server responds.

May contain traces of Fixedsys.

For the curious, here’s what it looks like in JSON-RPC. First, the client:

{
  "jsonrpc": "2.0",
  "method": "updateStatus",
  "id": 1294764619011,
  "params": [
    "Showing off the @hellodenby \"command line\" for a screenshot. #denby"
  ]
}

Then hopefully pretty soon after, the server:

{
  "jsonrpc": "2.0"
  "id": 1294764619011,
  "result": {
    "created_at": "Tue Jan 11 17:08:34 +0000 2011",
    "id": 24875324479115264,
    "id_str": "24875324479115264",
    "source": "<a href=\"http://www.hellodenby.com/\" rel=\"nofollow\">Denby DEVEL</a>"
    "text": "Showing off the @hellodenby \"command line\" for a screenshot. #denby",
    "user": { ... }
  }
}
This entry was posted in Development. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *