Skip to content

Commit 9ee39a3

Browse files
fix(example): prevent reconnecting after closing the connection (#13)
1 parent d1d50f0 commit 9ee39a3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

example/pages/index.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@
6767
Open connection
6868
</button>
6969
<button
70-
:disabled="!msgSend"
70+
:disabled="isSendDisabled"
7171
class="btn btn-blue"
72-
:class="{ 'cursor-not-allowed opacity-50': !msgSend }"
72+
:class="{ 'cursor-not-allowed opacity-50': isSendDisabled}"
7373
@click.prevent="sendMessage"
7474
>
7575
Send message
@@ -105,6 +105,9 @@ export default {
105105
closed: 'Connection closed!'
106106
}
107107
return statusMap[this.connectionStatus]
108+
},
109+
isSendDisabled () {
110+
return !this.msgSend || this.connectionStatus === 'closed'
108111
}
109112
},
110113
mounted () {
@@ -120,7 +123,7 @@ export default {
120123
this.toggleProperties()
121124
},
122125
closeConnection () {
123-
this.$socketManager.close()
126+
this.$socketManager.close(1000)
124127
this.toggleProperties(false)
125128
this.msgSend = ''
126129
this.msgReceived = ''

0 commit comments

Comments
 (0)