import * as messaging from 'messaging' ; var counter = 0 ; function sendMoreData ( ) { if ( counter < 100 ) { while ( messaging . peerSocket . bufferedAmount < 128 ) { messaging . peerSocket . send ( counter ++ ) ; } } } messaging . peerSocket . onbufferedamountdecrease = function ( ) { sendMoreData ( ) ; } ; sendMoreData ( ) ;