logic-helper
Version:
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
39 lines (34 loc) • 737 B
JavaScript
const WSS = require('ws-event-bus').default
function getClient(id) {
let ws = new WSS({
id,
url: 'ws://localhost:9504'
})
ws.on('wait', (data,response) => {
console.log(id + ' wait >>>>', response)
})
return ws
}
let w1 = getClient('w1')
let w2 = getClient('w2')
function click1(){
console.log(' click1')
w1.send('this is w1+', {
to: 'topo-server'
}).then(res => {
console.log('w1 get reply')
})
}
function click2(){
console.log(' click2',w2.waiting[0])
w2.reply(w2.waiting[0])
}
// document.getElementById('btn1').onclick = click1
// document.getElementById('btn2').onclick = click2
setTimeout(() => {
click1()
})
setTimeout(() => {
click2()
},3000)
setTimeout(() => {},100000)