first commit

This commit is contained in:
developertrinidad08
2023-01-16 18:11:14 -03:00
commit 7e6cf29479
233 changed files with 26791 additions and 0 deletions

21
node_modules/binaryjs/examples/README.md generated vendored Normal file
View File

@ -0,0 +1,21 @@
## BinaryJS Examples
### [Hello World](https://github.com/binaryjs/binaryjs/tree/master/examples/helloworld)
[View live demo](http://examples.binaryjs.com/hw.html)
Simple example that streams a flower picture to the client
### [Streaming File Upload](https://github.com/binaryjs/binaryjs/tree/master/examples/fileupload)
HTML5 drag and drop file upload with percentage progress
### [Image Share](https://github.com/binaryjs/binaryjs/tree/master/examples/imageshare)
Upload and broadcast images to other browsers (via file input)
### [ASCII Webcam](https://github.com/ericz/ascam)
[View live demo](http://ascam.ericzhang.com/)
[Requires Chrome 21+] Stream webcam video in ASCII (or not) without flash!

19
node_modules/binaryjs/examples/fileupload/README.md generated vendored Normal file
View File

@ -0,0 +1,19 @@
## Drag and Drop File Upload Example w/ Percentage completion
1. Run the server:
```
node server.js
```
2. Go to
```
http://localhost:9000/
```
3. Drag a file into the box. Percent transferred will be shown and the file will be saved in the example's directory.
Server code is contained in `server.js`
Client side code is contained in `public/index.html`

View File

@ -0,0 +1,46 @@
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script src="http://cdn.binaryjs.com/0/binary.js"></script>
<script>
var client = new BinaryClient('ws://localhost:9000');
// Wait for connection to BinaryJS server
client.on('open', function(){
var box = $('#box');
box.on('dragenter', doNothing);
box.on('dragover', doNothing);
box.text('Drag files here');
box.on('drop', function(e){
e.originalEvent.preventDefault();
var file = e.originalEvent.dataTransfer.files[0];
// Add to list of uploaded files
$('<div align="center"></div>').append($('<a></a>').text(file.name).prop('href', '/'+file.name)).appendTo('body');
// `client.send` is a helper function that creates a stream with the
// given metadata, and then chunks up and streams the data.
var stream = client.send(file, {name: file.name, size: file.size});
// Print progress
var tx = 0;
stream.on('data', function(data){
$('#progress').text(Math.round(tx+=data.rx*100) + '% complete');
});
});
});
// Deal with DOM quirks
function doNothing (e){
e.preventDefault();
e.stopPropagation();
}
</script>
</head>
<body>
<div id="progress" align="center">0% complete</div>
<div id="box" style="background: #eee; font-size: 26px; width: 400px; height: 300px;line-height: 300px; margin: 0 auto; text-align: center;">
Connecting...
</div>
</body>
</html>

34
node_modules/binaryjs/examples/fileupload/server.js generated vendored Normal file
View File

@ -0,0 +1,34 @@
var fs = require('fs');
var http = require('http');
// Serve client side statically
var express = require('express');
var app = express();
app.use(express.static(__dirname + '/public'));
var server = http.createServer(app);
// Start Binary.js server
var BinaryServer = require('../../').BinaryServer;
var bs = BinaryServer({server: server});
// Wait for new user connections
bs.on('connection', function(client){
// Incoming stream from browsers
client.on('stream', function(stream, meta){
//
var file = fs.createWriteStream(__dirname+ '/public/' + meta.name);
stream.pipe(file);
//
// Send progress back
stream.on('data', function(data){
stream.write({rx: data.length / meta.size});
});
//
});
});
//
//
server.listen(9000);
console.log('HTTP and BinaryJS server started on port 9000');

14
node_modules/binaryjs/examples/helloworld/README.md generated vendored Normal file
View File

@ -0,0 +1,14 @@
## Hello World example
1. Run the server:
```
node server.js
```
2. Open `index.html` in your browser
You should see a flower. If not, your browser probably doesn't support binary websockets.
Server code is contained in `server.js`
Client side code is contained in `index.html`

BIN
node_modules/binaryjs/examples/helloworld/flower.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

26
node_modules/binaryjs/examples/helloworld/index.html generated vendored Normal file
View File

@ -0,0 +1,26 @@
<html>
<head>
<script src="http://cdn.binaryjs.com/0/binary.js"></script>
<script>
// Connect to Binary.js server
var client = new BinaryClient('ws://localhost:9000');
// Received new stream from server!
client.on('stream', function(stream, meta){
// Buffer for parts
var parts = [];
// Got new data
stream.on('data', function(data){
parts.push(data);
});
stream.on('end', function(){
// Display new data in browser!
var img = document.createElement("img");
img.src = (window.URL || window.webkitURL).createObjectURL(new Blob(parts));
document.body.appendChild(img);
});
});
</script>
</head>
<body>
</body>
</html>

12
node_modules/binaryjs/examples/helloworld/server.js generated vendored Normal file
View File

@ -0,0 +1,12 @@
var BinaryServer = require('../../').BinaryServer;
var fs = require('fs');
// Start Binary.js server
var server = BinaryServer({port: 9000});
// Wait for new user connections
server.on('connection', function(client){
// Stream a flower as a hello!
var file = fs.createReadStream(__dirname + '/flower.png');
client.send(file);
});

View File

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<script src="http://cdn.binaryjs.com/0/binary.js"></script>
</head>
<body style="background-size:cover">
<input type="file" id="fileinput" accept="image/*" capture="camera" />
<script type="text/javascript">
// connect to the same host this was served from
var client = new BinaryClient('ws://' + document.location.host);
client.on('stream', function(stream, meta){
// collect stream data
var parts = [];
stream.on('data', function(data){
parts.push(data);
});
// when finished, set it as the background image
stream.on('end', function(){
var url = (window.URL || window.webkitURL).createObjectURL(new Blob(parts));
document.body.style.backgroundImage = 'url(' + url + ')';
});
});
// listen for a file being chosen
fileinput.addEventListener('change', function(event){
var file = event.target.files[0];
client.send(file);
}, false);
</script>
</body>
</html>

37
node_modules/binaryjs/examples/imageshare/server.js generated vendored Normal file
View File

@ -0,0 +1,37 @@
var fs = require('fs');
var http = require('http');
// Serve client side statically
var express = require('express');
var app = express();
app.use(express.static(__dirname + '/public'));
var server = http.createServer(app);
// Start Binary.js server
var BinaryServer = require('../../').BinaryServer;
// link it to express
var bs = BinaryServer({server: server});
// Wait for new user connections
bs.on('connection', function(client){
// Incoming stream from browsers
client.on('stream', function(stream, meta){
// broadcast to all other clients
for(var id in bs.clients){
if(bs.clients.hasOwnProperty(id)){
var otherClient = bs.clients[id];
if(otherClient != client){
var send = otherClient.createStream(meta);
stream.pipe(send);
}
}
}
});
});
server.listen(9000);
console.log('HTTP and BinaryJS server started on port 9000');