feat: Sec-WebSocket-Protocol header on WebSocket connections - resolved #1620

This commit is contained in:
Liyas Thomas
2021-06-15 14:44:23 +00:00
committed by GitHub
parent 499cd9d81b
commit 0a4251825b
2 changed files with 59 additions and 4 deletions

View File

@@ -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 @@
</li>
</div>
</ul>
<ul>
<li>
<div class="row-wrapper">
<label>{{ $t("protocols") }}</label>
</div>
</li>
</ul>
<ul
v-for="(input, index) of protocols"
:key="`input-${index}`"
:class="{ 'border-t': index == 0 }"
class="
border-b border-dashed
divide-y
md:divide-x
border-divider
divide-dashed divide-divider
md:divide-y-0
"
>
<li>
<input
v-model="protocols[index]"
:placeholder="$t('protocol_count', { count: index + 1 })"
name="message"
type="text"
/>
</li>
<div>
<li>
<button
v-tooltip.bottom="$t('delete')"
class="icon"
@click="deleteProtocol({ index })"
>
<i class="material-icons">delete</i>
</button>
</li>
</div>
</ul>
<ul>
<li>
<button class="icon" @click="addProtocol">
<i class="material-icons">add</i>
<span>{{ $t("add_new") }}</span>
</button>
</li>
</ul>
</AppSection>
<AppSection id="response" ref="response" :label="$t('communication')">
@@ -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)
},
},
}
</script>