- Copy code to your project
- Install dependencies:
npm i express body-parser cors argparse
node server.js --savePath ./save/directory/ --port 4000
/** | |
* | |
* @param {string} data base64 encoded png image | |
* @param {string} fileName | |
* @returns {Promise<void>} | |
*/ | |
export async function savePng(data, filePath, {port = 3001, host = "http://localhost"} = {}) { | |
const response = await fetch(`${host}:${port}`, { | |
body: JSON.stringify({data, filePath}), | |
method: "POST", |
isOculusGo() { | |
return /Pacific.+OculusBrowser/i.test(window.navigator.userAgent) // oculus browser | |
|| /SAMSUNG.?Pacific/i.test(window.navigator.userAgent); // samsung internet | |
} | |
isOculusQuest() { | |
return /Quest.+OculusBrowser/i.test(window.navigator.userAgent); // oculus browser | |
// TODO add support for Samsung Internet when (and if) it is released for Quest | |
} |
componentDidUpdate(prevProps, prevState) { | |
if(this.props && prevProps) Object.entries(this.props).forEach(([key, val]) => | |
prevProps[key] !== val && console.log(`Prop '${key}' changed ${JSON.stringify(prevProps[key])} -> ${JSON.stringify(this.props[key])}`) | |
); | |
if(this.state && prevState) Object.entries(this.state).forEach(([key, val]) => | |
prevState[key] !== val && console.log(`State '${key}' changed`) | |
); | |
} | |
Simple demo of how consul service discovery works within Node and Docker.
In this example there are 3 containers: master and 2 workers. When master receives a request from a client, it leverages consul to find all workers in the cluster. After that it performs GET request to a random worker and pipes it's response to client.