Permalink
Browse files

Step 7. Multi-clients

  • Loading branch information...
alexeybondarenko committed Aug 6, 2017
1 parent 703003e commit 02cfc6ed4091218c8f5a292fda1aa4ec46d0e4ea
Showing with 6 additions and 3 deletions.
  1. +5 −2 client/app.js
  2. +1 −1 server/index.js
@@ -23,10 +23,13 @@
client.on('open', function () {
MIDIStream = client.createStream();
MIDIStream.on('data', handleReceiveAudioData);
MIDIStream.on('end', handleEndAudioStream);
});
client.on('stream', function (stream) {
stream.on('data', handleReceiveAudioData);
stream.on('end', handleEndAudioStream);
})
function handleReceiveAudioData(data) {
console.log('receive audio data', data);
context.decodeAudioData(data, playSound);
@@ -50,7 +50,7 @@ socket.on('connection', (client) => {
stream.on('data', (data) => {
console.log(data);
const tone = data.readInt8(1);
playTone(tone, stream);
Object.keys(socket.clients).map(i => playTone(tone, socket.clients[i].createStream()));
});
stream.on('end', () => {

0 comments on commit 02cfc6e

Please sign in to comment.