mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
Update http-external-ws.js
use classic functions instead of es6 fix peers.find should be peers.findIndex for splice.
This commit is contained in:
parent
85ae140512
commit
4a5ab4122b
@ -42,13 +42,13 @@ function acceptConnection( connection ) {
|
||||
gunPeers.push( connection );
|
||||
gun.on('out', (msg)=>{
|
||||
msg = JSON.stringify({headers:{},body:msg});
|
||||
gunPeers.forEach( (peer)=>{ peer.send( msg ) })
|
||||
gunPeers.forEach( function(peer){ peer.send( msg ) })
|
||||
})
|
||||
connection.on( 'error',(error)=>{console.log( "WebSocket Error:", error } );
|
||||
connection.on( 'message',(msg)=>{gun.on('in',JSON.parse( msg.utf8Data).body)})
|
||||
connection.on( 'close', (reason,desc)=>{
|
||||
connection.on( 'error',function(error){console.log( "WebSocket Error:", error } );
|
||||
connection.on( 'message',function(msg){gun.on('in',JSON.parse( msg.utf8Data).body)})
|
||||
connection.on( 'close', function(reason,desc){
|
||||
// gunpeers gone.
|
||||
var i = peers.find( p=>p===connection );
|
||||
var i = peers.findIndex( function(p){return p===connection} );
|
||||
if( i >= 0 )
|
||||
gunPeers.splice( i, 1 );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user