import * as messaging from 'messaging' ; messaging . peerSocket . onopen = function ( ) { sendMessage ( ) ; } ; messaging . peerSocket . onerror = function ( err ) { console . log ( 'Connection error: ' + err . code + ' - ' + err . message ) ; } ; function sendMessage ( ) { var data = { title : 'My test data' , isTest : true , records : [ 1 , 2 , 3 , 4 ] , } ; if ( messaging . peerSocket . readyState === messaging . peerSocket . OPEN ) { messaging . peerSocket . send ( data ) ; } }