This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "0001ETGYTW00GW0X476W5TVBFE", | |
"appId": "ye-rkQ", | |
"clientId": "id-q2li38voycq", | |
"platform": "ios", | |
"formFactor": "phone", | |
"metadata": {}, | |
"deviceSecret": "4hcCuDNGW349NHokMgZcxo4zud1ASy8pnA1ETs3fsCE=", | |
"push": { | |
"recipient": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"deviceId": "0001ETGYTW00GW0X476W5TVBFE", | |
"channel": "push:gmtest" | |
} | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"clientId": "id-wvzwa21jxm", | |
"channel": "push:gmtest" | |
} | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
channel: <string>, | |
clientId: <string, only present when deviceId is not present> | |
deviceId: <string, only present when clientId is not present>, | |
}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
id: <string>, | |
clientId: <optional, string> | |
platform: <string> | |
formFactor: <string>, | |
metadata: <object>, | |
updateToken: <string>, | |
push: { | |
recipient: { | |
transportType: <string>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X POST https://rest.ably.io/channels/fox-gin/messages \ | |
-u '6QdTiA.O9vBCw:8glD3fRTNhSEVJC5' \ | |
--data 'name=greeting&data=hello' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if(! (gem list -i iStats)) | |
then | |
gem install iStats | |
exit 0 | |
fi | |
myDeviceTemp=$(istats | awk '{if($1=="CPU") { print "CPUtemp:" $3 }; } END { }') | |
myBatteryTemp=$(istats | awk '{if($1=="Battery") { print "BatteryTemp:" $3 }; } END { }') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
socket.on('data', buffer => { | |
const message = parseMessage(buffer); | |
if (message) { | |
// For our convenience, so we can see what the client sent | |
console.log(message); | |
// We'll just send a hardcoded message in this example | |
socket.write(constructReply({ message: 'Hello from the server!' })); | |
} else if (message === null) { | |
console.log('WebSocket connection closed by the client.'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function constructReply (data) { | |
// Convert the data to JSON and copy it into a buffer | |
const json = JSON.stringify(data) | |
const jsonByteLength = Buffer.byteLength(json); | |
// Note: we're not supporting > 65535 byte payloads at this stage | |
const lengthByteCount = jsonByteLength < 126 ? 0 : 2; | |
const payloadLength = lengthByteCount === 0 ? jsonByteLength : 126; | |
const buffer = Buffer.alloc(2 + lengthByteCount + jsonByteLength); | |
// Write out the first byte, using opcode `1` to indicate that the message | |
// payload contains text data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseMessage (buffer) { | |
// …all of the above, then: | |
const json = data.toString('utf8'); return JSON.parse(json); | |
} |