Skip to content
Snippets Groups Projects
Commit c8d3d07c authored by Sami Spets's avatar Sami Spets
Browse files

client gets the list of available streams

parent 12bce041
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
"start": "react-scripts start", "start": "react-scripts start",
"build": "react-scripts build", "build": "react-scripts build",
"test": "react-scripts test --env=jsdom", "test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject" "eject": "react-scripts eject",
"buildFull": "react-scripts build && cp -r build ~/work/ftl/web-service/server"
}, },
"browserslist": { "browserslist": {
"production": [ "production": [
......
...@@ -36,13 +36,14 @@ const App = () => { ...@@ -36,13 +36,14 @@ const App = () => {
window.location.reload(); window.location.reload();
} }
if(window.localStorage.getItem('token')){ // if(window.localStorage.getItem('token')){
return ( // return (
<Streams clearCookies={clearCookies}/> //
) // )
} // }
return ( return (
<Login handleLogin={handleLogin} /> <Streams clearCookies={clearCookies}/>
// <Login handleLogin={handleLogin} />
) )
} }
......
...@@ -11,24 +11,40 @@ The user will be redirected to Stream.js file ...@@ -11,24 +11,40 @@ The user will be redirected to Stream.js file
const Streams = ({clearCookies}) => { const Streams = ({clearCookies}) => {
const [thumbnails, setThumbnails] = useState([]); const [thumbnails, setThumbnails] = useState([]);
useEffect(() => {
setThumbnails(testData.thumbnail);
console.log('streams')
}, [])
const renderThumbnails = () => { useEffect( async () => {
const photos = thumbnails.map(i => <div style={{'paddingTop': '25px'}}><img alt='robots' src={i.video} width='150px'/><p style={{'margin': 'none'}}>viewers: {i.viewers}</p></div>) const jsonThumbnails = await fetch('/streams/');
return photos; const realThumbnails = await jsonThumbnails.json();
setThumbnails(realThumbnails);
console.log('THUMBNAILS', thumbnails)
}, [])
/**
* Fetch the thumbnails
* setInterval() fetch every 1 second
*/
const fetchThumbnails = async () => {
const jsonThumbnails = await fetch('/streams/');
const realThumbnails = await jsonThumbnails.json();
return realThumbnails;
} }
const renderThumbnails = async () => {
const thumbs = await fetchThumbnails()
console.log('before', thumbnails)
setThumbnails((thumbs));
console.log('after', thumbnails)
return thumbnails
}
return( return(
<div style={{'margin': 'auto', 'textAlign': 'center'}}> <div style={{'margin': 'auto', 'textAlign': 'center'}}>
<h1>Streams component works!!</h1> <h1>Streams component works!!</h1>
<h2>Namibia here we come!</h2> <h2>Namibia here we come!</h2>
<button onClick={clearCookies}>Logout</button> <button onClick={clearCookies}>Logout</button>
<br /> <br />
{renderThumbnails()} <button onClick={() => renderThumbnails()}></button>
</div> </div>
) )
} }
......
...@@ -114,8 +114,10 @@ RGBDStream.prototype.subscribe = function() { ...@@ -114,8 +114,10 @@ RGBDStream.prototype.subscribe = function() {
} }
RGBDStream.prototype.pushFrames = function(latency, spacket, packet) { RGBDStream.prototype.pushFrames = function(latency, spacket, packet) {
if (spacket[1] & 0x1) this.depth = packet[4]; if (packet[0] === 0){
else this.rgb = packet[4]; if (spacket[1] & 0x1) this.depth = packet[4];
else this.rgb = packet[4];
}
console.log("Frame = ", packet[0], packet[1]); console.log("Frame = ", packet[0], packet[1]);
...@@ -149,6 +151,7 @@ app.get('/streams', (req, res) => { ...@@ -149,6 +151,7 @@ app.get('/streams', (req, res) => {
app.get('/stream/rgb', (req, res) => { app.get('/stream/rgb', (req, res) => {
let uri = req.query.uri; let uri = req.query.uri;
if (uri_data.hasOwnProperty(uri)) { if (uri_data.hasOwnProperty(uri)) {
uri_data[uri].peer.send("get_stream", uri, 10, 9, [Peer.uuid], uri);
res.writeHead(200, {'Content-Type': 'image/jpeg'}); res.writeHead(200, {'Content-Type': 'image/jpeg'});
res.end(uri_data[uri].rgb); res.end(uri_data[uri].rgb);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment