-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.js
81 lines (80 loc) · 1.97 KB
/
client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
Created by: Lightnet
LICENSE: MIT
Information: Web Client.
*/
import "@babel/polyfill";
import Vue from 'vue';
//https://vuejs.org/v2/api/
Vue.config.productionTip = false;
Vue.config.silent = true;
Vue.config.devtools = false;
import Gun from 'gun/gun'; //browser
import 'gun/sea';
import VueGun from 'vue-gun';
//Vue.component('hello-component', require('./components/HelloComponent').default);
/*
new Vue({
el: '#app',
data: {
message: 'Hello from Webpack'
}
});
*/
//import HelloComponent from './components/HelloComponent';
//import TestChatComponent from './components/TestChatComponent';
import App from './App.vue';
var gun;
if(location.origin == 'http://localhost:3000'){
gun = Gun({
peers:['http://localhost:8080' + '/gun'],
secure: false, //not added?
});
console.log('local gun.js');
}else{
gun = Gun(location.origin + '/gun');
console.log('host gun.js');
}
gun.on('hi', peer => {//peer connect
console.log('peer connect!');
//displayeffectmessage('Connect to peer!');
});
gun.on('bye', (peer)=>{// peer disconnect
console.log('Disconnected from peer!');
});
//Vue.prototype.$gun = gun;
Vue.use(VueGun, {
gun: gun // your gun instance
});
/*
Vue.use(VueGun, {
peers: ['http://localhost:8080/gun']
});
*/
//console.log(Vue);
function init(){
new Vue({
el: '#app',
components:{
App
},
data: {
//message: 'Hello from Webpack'
},
render: h => h(App),
mounted:function(){
/*
this.$gun.on('hi', peer => {//peer connect
console.log('peer connect!');
//displayeffectmessage('Connect to peer!');
});
this.$gun.on('bye', (peer)=>{// peer disconnect
console.log('Disconnected from peer!');
});
*/
},
});
console.log("Init App...");
}
window.addEventListener("load",init);
//console.log("Init App...");