-
@@ -117,6 +135,22 @@ export default {
subscriptionState: false,
}
},
+ computed: {
+ validUrl() {
+ return this.isUrlValid
+ },
+ canpublish() {
+ return this.pub_topic !== "" && this.msg !== "" && this.connectionState
+ },
+ cansubscribe() {
+ return this.sub_topic !== "" && this.connectionState
+ },
+ },
+ watch: {
+ url() {
+ this.debouncer()
+ },
+ },
mounted() {
if (process.browser) {
this.worker = this.$worker.createRejexWorker()
@@ -126,22 +160,6 @@ export default {
destroyed() {
this.worker.terminate()
},
- watch: {
- url(val) {
- this.debouncer()
- },
- },
- computed: {
- validUrl() {
- return this.isUrlValid
- },
- canpublish() {
- return this.pub_topic != "" && this.msg != "" && this.connectionState
- },
- cansubscribe() {
- return this.sub_topic != "" && this.connectionState
- },
- },
methods: {
debouncer: debounce(function () {
this.worker.postMessage({ type: "ws", url: this.url })
@@ -158,10 +176,10 @@ export default {
ts: new Date().toLocaleTimeString(),
},
]
- let parseUrl = new URL(this.url)
+ const parseUrl = new URL(this.url)
this.client = new Paho.Client(
parseUrl.hostname,
- parseUrl.port != "" ? Number(parseUrl.port) : 8081,
+ parseUrl.port !== "" ? Number(parseUrl.port) : 8081,
"postwoman"
)
this.client.connect({
@@ -267,7 +285,9 @@ export default {
})
} catch (e) {
this.log.push({
- payload: this.$t("error_occurred") + `while subscribing to topic: ${this.sub_topic}`,
+ payload:
+ this.$t("error_occurred") +
+ `while subscribing to topic: ${this.sub_topic}`,
source: "info",
color: "#ff5555",
ts: new Date().toLocaleTimeString(),
diff --git a/components/realtime/Sse.vue b/components/realtime/Sse.vue
index 69e5e433c..3e03d48a3 100644
--- a/components/realtime/Sse.vue
+++ b/components/realtime/Sse.vue
@@ -1,28 +1,28 @@
-
+
-
-
{{ !connectionSSEState ? $t("start") : $t("stop") }}
@@ -36,7 +36,12 @@
-
+
-
@@ -63,8 +68,13 @@ export default {
},
}
},
+ computed: {
+ serverValid() {
+ return this.isUrlValid
+ },
+ },
watch: {
- server(val) {
+ server() {
this.debouncer()
},
},
@@ -77,11 +87,6 @@ export default {
destroyed() {
this.worker.terminate()
},
- computed: {
- serverValid() {
- return this.isUrlValid
- },
- },
methods: {
debouncer: debounce(function () {
this.worker.postMessage({ type: "sse", url: this.server })
@@ -106,7 +111,7 @@ export default {
if (typeof EventSource !== "undefined") {
try {
this.sse = new EventSource(this.server)
- this.sse.onopen = (event) => {
+ this.sse.onopen = () => {
this.connectionSSEState = true
this.events.log = [
{
@@ -120,10 +125,10 @@ export default {
icon: "sync",
})
}
- this.sse.onerror = (event) => {
+ this.sse.onerror = () => {
this.handleSSEError()
}
- this.sse.onclose = (event) => {
+ this.sse.onclose = () => {
this.connectionSSEState = false
this.events.log.push({
payload: this.$t("disconnected_from", { name: this.server }),
diff --git a/components/realtime/Websocket.vue b/components/realtime/Websocket.vue
index 23cd8c97a..ac48f3846 100644
--- a/components/realtime/Websocket.vue
+++ b/components/realtime/Websocket.vue
@@ -1,29 +1,29 @@
-
+
-
-
{{ !connectionState ? $t("connect") : $t("disconnect") }}
@@ -37,7 +37,12 @@
-
+
-
@@ -48,14 +53,14 @@
@@ -65,8 +70,8 @@
id="send"
name="send"
:disabled="!connectionState"
- @click="sendMessage"
class="rounded-b-lg md:rounded-bl-none md:rounded-br-lg"
+ @click="sendMessage"
>
{{ $t("send") }}
@@ -94,9 +99,19 @@ export default {
log: null,
input: "",
},
- currentIndex: -1, //index of the message log array to put in input box
+ currentIndex: -1, // index of the message log array to put in input box
}
},
+ computed: {
+ urlValid() {
+ return this.isUrlValid
+ },
+ },
+ watch: {
+ url() {
+ this.debouncer()
+ },
+ },
mounted() {
if (process.browser) {
this.worker = this.$worker.createRejexWorker()
@@ -106,16 +121,6 @@ export default {
destroyed() {
this.worker.terminate()
},
- computed: {
- urlValid() {
- return this.isUrlValid
- },
- },
- watch: {
- url(val) {
- this.debouncer()
- },
- },
methods: {
debouncer: debounce(function () {
this.worker.postMessage({ type: "ws", url: this.url })
@@ -139,7 +144,7 @@ export default {
]
try {
this.socket = new WebSocket(this.url)
- this.socket.onopen = (event) => {
+ this.socket.onopen = () => {
this.connectionState = true
this.communication.log = [
{
@@ -153,10 +158,10 @@ export default {
icon: "sync",
})
}
- this.socket.onerror = (event) => {
+ this.socket.onerror = () => {
this.handleError()
}
- this.socket.onclose = (event) => {
+ this.socket.onclose = () => {
this.connectionState = false
this.communication.log.push({
payload: this.$t("disconnected_from", { name: this.url }),
@@ -215,20 +220,24 @@ export default {
this.communication.input = ""
},
walkHistory(direction) {
- const clientMessages = this.communication.log.filter(({ source }) => source === "client")
+ const clientMessages = this.communication.log.filter(
+ ({ source }) => source === "client"
+ )
const length = clientMessages.length
switch (direction) {
case "up":
if (length > 0 && this.currentIndex !== 0) {
- //does nothing if message log is empty or the currentIndex is 0 when up arrow is pressed
+ // does nothing if message log is empty or the currentIndex is 0 when up arrow is pressed
if (this.currentIndex === -1) {
this.currentIndex = length - 1
- this.communication.input = clientMessages[this.currentIndex].payload
+ this.communication.input =
+ clientMessages[this.currentIndex].payload
} else if (this.currentIndex === 0) {
this.communication.input = clientMessages[0].payload
} else if (this.currentIndex > 0) {
this.currentIndex = this.currentIndex - 1
- this.communication.input = clientMessages[this.currentIndex].payload
+ this.communication.input =
+ clientMessages[this.currentIndex].payload
}
}
break
@@ -239,7 +248,8 @@ export default {
this.communication.input = ""
} else if (this.currentIndex < length - 1) {
this.currentIndex = this.currentIndex + 1
- this.communication.input = clientMessages[this.currentIndex].payload
+ this.communication.input =
+ clientMessages[this.currentIndex].payload
}
}
break