mirror of
https://github.com/amark/gun.git
synced 2025-06-06 06:06:50 +00:00
better env detection
This commit is contained in:
parent
5f153a4912
commit
6795ef04a8
@ -3,9 +3,15 @@ var Gun = (typeof window !== "undefined")? window.Gun : require('../gun');
|
||||
Gun.on('create', function(root){
|
||||
this.to.next(root);
|
||||
var opt = root.opt;
|
||||
if(typeof window !== "undefined"){
|
||||
return; // do nothing for now - Chrome extensions could use multicast though
|
||||
|
||||
try {
|
||||
var dgram = require("dgram");
|
||||
var process = require("process");
|
||||
} catch (e) {
|
||||
console.log('multicast is not available');
|
||||
return;
|
||||
}
|
||||
|
||||
if(false === opt.multicast){ return }
|
||||
opt.multicast = opt.multicast || {};
|
||||
|
||||
@ -15,9 +21,6 @@ Gun.on('create', function(root){
|
||||
var DEFAULT_GUN_PORT = 8765;
|
||||
var ENC = 'utf8';
|
||||
|
||||
var dgram = require("dgram");
|
||||
var process = require("process");
|
||||
|
||||
socket = dgram.createSocket({ type: "udp4", reuseAddr: true });
|
||||
|
||||
socket.bind(PORT);
|
||||
|
Loading…
x
Reference in New Issue
Block a user