-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpush.js
More file actions
24 lines (22 loc) · 780 Bytes
/
push.js
File metadata and controls
24 lines (22 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var channel = function( pos) {
// get content using web socket
var socket = new WebSocket( "ws://" + $.io.bip + ":5000");
socket.binaryType = "arraybuffer";
socket.onopen = function( h) {
socket.send( ( CHUNKSIZE * pos) + ' ' + CHUNKSIZE + ' ' + STREAMS + ' ' + THRU + ' ' + LASTPOS);
pos = pos * CHUNKSIZE;
}
socket.onmessage = function( h) {
var data;
try { data = new Uint8Array( h.data); }
catch( e) { return; } // error in data type, hoping for next data piece
//POSES[ pos] += data.length;
//console.log( 'put pos/length', pos, data.length);
BUFFER[ '' + pos] = data;
pos += STREAMS * CHUNKSIZE;
//buffer.append( data);
//console.log( POSES);
}
socket.onclose = function( h) { }
}
for ( var i = 0; i < STREAMS; i++) eval( channel)( i);