Added websocket test
This commit is contained in:
parent
e1dfdbba76
commit
988c7eb7b4
|
@ -485,8 +485,9 @@
|
||||||
outline
|
outline
|
||||||
color="grey"
|
color="grey"
|
||||||
@click="copyText(lnurlValue, 'LNURL copied to clipboard!')"
|
@click="copyText(lnurlValue, 'LNURL copied to clipboard!')"
|
||||||
>Copy LNURL</q-btn
|
>Copy LNURL</q-btn>
|
||||||
>
|
<br />
|
||||||
|
{{ websocketMessage }}
|
||||||
<br />
|
<br />
|
||||||
<div class="row q-mt-lg q-gutter-sm">
|
<div class="row q-mt-lg q-gutter-sm">
|
||||||
<q-btn
|
<q-btn
|
||||||
|
@ -534,6 +535,7 @@
|
||||||
filter: '',
|
filter: '',
|
||||||
currency: 'USD',
|
currency: 'USD',
|
||||||
lnurlValue: '',
|
lnurlValue: '',
|
||||||
|
websocketMessage: '',
|
||||||
switches: 0,
|
switches: 0,
|
||||||
lnurldeviceLinks: [],
|
lnurldeviceLinks: [],
|
||||||
lnurldeviceLinksObj: [],
|
lnurldeviceLinksObj: [],
|
||||||
|
@ -631,11 +633,12 @@
|
||||||
this.qrCodeDialog.data = _.clone(lnurldevice)
|
this.qrCodeDialog.data = _.clone(lnurldevice)
|
||||||
this.qrCodeDialog.data.url =
|
this.qrCodeDialog.data.url =
|
||||||
window.location.protocol + '//' + window.location.host
|
window.location.protocol + '//' + window.location.host
|
||||||
this.lnurlValueFetch(this.qrCodeDialog.data.switches[0][3])
|
this.lnurlValueFetch(this.qrCodeDialog.data.switches[0][3], this.qrCodeDialog.data.switches[0][0])
|
||||||
this.qrCodeDialog.show = true
|
this.qrCodeDialog.show = true
|
||||||
},
|
},
|
||||||
lnurlValueFetch: function (lnurl) {
|
lnurlValueFetch: function (lnurl, switchId) {
|
||||||
this.lnurlValue = lnurl
|
this.lnurlValue = lnurl
|
||||||
|
this.websocketConnector('wss://' + window.location.host + '/lnurldevice/ws/' + switchId)
|
||||||
},
|
},
|
||||||
addSwitch: function () {
|
addSwitch: function () {
|
||||||
var self = this
|
var self = this
|
||||||
|
@ -797,6 +800,21 @@
|
||||||
LNbits.utils.notifyApiError(error)
|
LNbits.utils.notifyApiError(error)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
websocketConnector: function(websocketUrl){
|
||||||
|
if ("WebSocket" in window) {
|
||||||
|
this.websocketMessage = "Websocket connected"
|
||||||
|
var ws = new WebSocket(websocketUrl)
|
||||||
|
ws.onmessage = function (evt) {
|
||||||
|
var received_msg = evt.data
|
||||||
|
this.websocketMessage = "Message recieved: " + received_msg
|
||||||
|
}
|
||||||
|
ws.onclose = function() {
|
||||||
|
this.websocketMessage = "Connection closed"
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
this.websocketMessage = "WebSocket NOT supported by your Browser!"
|
||||||
|
}
|
||||||
|
},
|
||||||
clearFormDialoglnurldevice() {
|
clearFormDialoglnurldevice() {
|
||||||
this.formDialoglnurldevice.data = {
|
this.formDialoglnurldevice.data = {
|
||||||
lnurl_toggle: false,
|
lnurl_toggle: false,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user