What does the future hold when we have billions of users with personal smart phones? Like the PCs automating the office, smart phones will transform our social life. The Stanford MobiSocial Computing Laboratory focuses on creating novel user experience, system architecture, infrastructure design, development frameworks, and security protocols for the programmable open mobile internet (POMI) by year 2020.



Junction Tips and Tricks

Debugging

There are two important tips to help debug your Junction application. First, don't forget that Junction uses XMPP's Multi-User Chat profile for communication. So, using a standard XMPP client, you can join the room and send/receive messages to your activity.

Second, you can force your activity to be in a fixed session in one of two ways: Either use a URI to bind your actor to a Junction activity, or specify a session ID on your Activity Script:

  var ascript = {ad: "my.demo.app", ... }
      ascript.sessionID = "fixedDebugSession";

Javascript

Often, the structure of your Junction application may take you down the path of writing something like the following:

var actor = {};
actor.onMessageReceived =
  function(msg,header) {
    if (msg.action == "update") {
      // do something
    }
    
    if (msg.action == "foo") { 
      // do something else
    }
  
    if (msg.action == "bar") {
     // do something more
    }
  };
For larger apps, this can make your code pretty difficult to maintain.

One alternative is to do something like the following:


function MyActor() {

  this.onUpdate = function(msg,header) {
    // do something
  }

  this.onFoo = function(msg,header) {
    // do something else
  }

  this.onBar = function(msg,header) {
    // do something more
  }


  this.onMessageReceived =
    function(msg,header) {
      if (msg.action in this.registry) {
        this.registry[msg.action](msg,header);
    }
  };

  
  this.registry = {};
  this.registry["update"] = this.onUpdate;
  this.registry["foo"] = this.onFoo;
  this.registry["bar"] = this.onBar;
}


There are countless ways to be creative with metaprogramming, and we'd love to hear your solution.

Send us your tips

Have something to share? We'd be more than happy to hear what you've got! You can send your ideas to (bjdodson at cs dot stanford dot edu).