From 0a4251825b1151efff596f85a947bd09eda56567 Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Tue, 15 Jun 2021 14:44:23 +0000 Subject: [PATCH] feat: Sec-WebSocket-Protocol header on WebSocket connections - resolved #1620 --- components/realtime/Websocket.vue | 59 +++++++++++++++++++++++++++++-- lang/en-US.json | 4 ++- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/components/realtime/Websocket.vue b/components/realtime/Websocket.vue index f5cee89af..c51769dce 100644 --- a/components/realtime/Websocket.vue +++ b/components/realtime/Websocket.vue @@ -10,7 +10,6 @@ type="url" spellcheck="false" :class="{ error: !urlValid }" - class="md:rounded-bl-lg" :placeholder="$t('url')" @keyup.enter="urlValid ? toggleConnection() : null" /> @@ -22,7 +21,6 @@ id="connect" :disabled="!urlValid" name="connect" - class="rounded-b-lg md:rounded-bl-none md:rounded-br-lg" @click="toggleConnection" > {{ !connectionState ? $t("connect") : $t("disconnect") }} @@ -35,6 +33,54 @@ + + + @@ -95,6 +141,7 @@ export default { input: "", }, currentIndex: -1, // index of the message log array to put in input box + protocols: [], } }, computed: { @@ -138,7 +185,7 @@ export default { }, ] try { - this.socket = new WebSocket(this.url) + this.socket = new WebSocket(this.url, this.protocols) this.socket.onopen = () => { this.connectionState = true this.communication.log = [ @@ -250,6 +297,12 @@ export default { break } }, + addProtocol() { + this.protocols.push("") + }, + deleteProtocol({ index }) { + this.$delete(this.protocols, index) + }, }, } diff --git a/lang/en-US.json b/lang/en-US.json index e8a81fe08..2c81a8d71 100644 --- a/lang/en-US.json +++ b/lang/en-US.json @@ -339,5 +339,7 @@ "we_sent_magic_link": "We sent you a magic link!", "we_sent_magic_link_description": "We sent an email to {email}. It contains a magic link that’ll log you in.", "hide_sidebar": "Hide sidebar", - "show_sidebar": "Show sidebar" + "show_sidebar": "Show sidebar", + "protocols": "Protocols", + "protocol_count": "protocol {count}" }