- establish WSS connection
var websocket = new WebSocket("wss://push.services.mozilla.com");
websocket.onopen = function(event) {alert("OPEN");};
websocket.onclose = function(e) {alert('closed')};
websocket.onmessage = function(e) {console.log(e.data); };
once 'open'ed send HELLO:
var helloMsg = {messageType: "hello",uaid: "",channelIDs: []};
websocket.send(JSON.stringify( helloMsg ));
After payload received, did an register:
var reg = {"messageType": "register","channelID": "d9b74644-4f97-46aa-b8fa-9393985cd6cd"};
websocket.send(JSON.stringify( reg ));
From that payload, use the pushEndpoint
URL string, in a cURL, like:
curl -i --header "Content-Type:application/x-www-form-urlencoded" -X PUT -d "version=2"
https://push.services.mozilla.com/update/MGlYke2SrEmYE8ceyuSTwxawxuEJnMeHtTCFDckvUo9Gwat44C5Z5vjlQEd1od1hj6o38UB6Ytc5xgXwSLAH2VS8qKyZ1eLNTQSX6_AEeH73ohUy2A==
And noticed a logged update :-)
Hi matzew,
i am trying to make this work as a proof of concept for another project, but i always get the websocket closed as soon as the hello message is sent.
The protocol looks compliant with the documentation.
Am i looking at the proper documentation or has the server changed?
If the server changed, where can i look for documentation? and, could you update this gist?
Regards,
Vicente.