-
Notifications
You must be signed in to change notification settings - Fork 17
SimplePush v1
Guillermo López Leal edited this page May 27, 2013
·
10 revisions
And checkout v1-fix
branch.
You can change the src/config.js
file to configure everything.
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"
- Start MongoDB and RabbitMQ, with default configurations
- Go to
src/
and thennode start.js
Doing make tests
on the root will execute all unit and functional tests.
TODO
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.