Skip to content
Guillermo López Leal edited this page May 27, 2013 · 10 revisions

Clone

And checkout v1-fix branch.

Configure

You can change the src/config.js file to configure everything.

Provision of UDP

Go to scripts/ and awk -f load_mcc_mnc_onmongo.awk mcc_mnc_list.txt (this will load all carrier networks to the database).

If you want to add a UDP wakeup server, you need to do: ./add_wakeupserver_ip.sh MCC MNC ip:port

For example: ./add_wakeupserver_ip.sh 214 07 127.0.0.1:8090

Also, you need to provision the networks your server is wakening up:

./add_wakeupserver_networks.sh 214 07 "192.168.0.0/16"

Starting

  1. Start MongoDB and RabbitMQ, with default configurations
  2. Go to src/ and then node start.js

Testing

Doing make tests on the root will execute all unit and functional tests.

Playing with real stuff

Device

TODO

Browser

Open the Firefox Scratchpad in Tools > Developer tools > Scratchpad, and paste:

var ws = new WebSocket('wss://localhost:8080', 'push-notification');

ws.onmessage = function(msg) {
    //console.log('MSG-->' + msg.data);
    try {
        var json = JSON.parse(msg.data);
    } catch (e) {
        console.log('Invalid JSON');
    }
    
    switch(json.messageType) {
        case 'hello':
            uaid = json.uaid;
            console.log('Received a uaid in HELLO message ' + uaid);
            break;
        case 'register':
            pushEndpoint = json.pushEndpoint;
            console.log('Received a pushEndPoint in REGISTER message ' + pushEndpoint);
            break;
        case 'notification':
            console.log('Received a notification in NOTIFICATION message ' + JSON.stringify(json.updates));
            version = json.updates[0].version;
            sendACK(channelID, version);
            break;
        default:
            console.log('WTF??');
            break;
    }
    return;
};

var sendACK = function(ch, vs) {
    ws.send('{"messageType": "ack", "updates":[{"channelID": "' + ch + '", "version": "' + vs + '"}]}');
}

var uaid = null;
var channelID = "testApp";
var version = null;
var pushEndpoint = null;

window.setTimeout(function() {
    ws.send('{ "messageType": "hello"}');
}, 200);

window.setTimeout(function() {
    ws.send('{ "channelID": "' + channelID + '", "messageType":"register"}');
}, 400);

// Now the pushEndpoint will be printed on the Console. Copy&paste it, and use a REST client (or your choice)
// and send a PUT to that URL with the body version=<v> where <v> is the version you want to send.
// Then, the console will output something like:
// "Received a notification in NOTIFICATION message [{"channelID":"testApp","version":"5"}]"
// It is, then, ACKed automatically.
Clone this wiki locally