mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
Handle batched messages.
Failure to handle batch messages causes half communcaitions failures... (the clients were using a batching protocol, while all servers were based on this example...
This commit is contained in:
parent
f43a0212b0
commit
545f995a3e
@ -46,7 +46,12 @@ function acceptConnection( connection ) {
|
||||
gunPeers.push( connection );
|
||||
connection.on( 'error',function(error){console.log( "WebSocket Error:", error) } );
|
||||
|
||||
connection.on( 'message',function(msg){gun.on('in',JSON.parse( msg))})
|
||||
connection.on('message', function (msg) {
|
||||
msg = JSON.parse(msg)
|
||||
if ("forEach" in msg) msg.forEach(m => gun.on('in', JSON.parse(m)));
|
||||
else gun.on('in', msg)
|
||||
})
|
||||
|
||||
connection.on( 'close', function(reason,desc){
|
||||
// gunpeers gone.
|
||||
var i = gunPeers.findIndex( function(p){return p===connection} );
|
||||
|
Loading…
x
Reference in New Issue
Block a user