File tree 1 file changed +10
-9
lines changed
packages/core/useWebSocket
1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -171,15 +171,6 @@ export function useWebSocket<Data = any>(
171
171
172
172
let pongTimeoutWait : ReturnType < typeof setTimeout > | undefined
173
173
174
- // Status code 1000 -> Normal Closure https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code
175
- const close : WebSocket [ 'close' ] = ( code = 1000 , reason ) => {
176
- if ( ! wsRef . value )
177
- return
178
- explicitlyClosed = true
179
- heartbeatPause ?.( )
180
- wsRef . value . close ( code , reason )
181
- }
182
-
183
174
const _sendBuffer = ( ) => {
184
175
if ( bufferedData . length && wsRef . value && status . value === 'OPEN' ) {
185
176
for ( const buffer of bufferedData )
@@ -193,6 +184,16 @@ export function useWebSocket<Data = any>(
193
184
pongTimeoutWait = undefined
194
185
}
195
186
187
+ // Status code 1000 -> Normal Closure https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code
188
+ const close : WebSocket [ 'close' ] = ( code = 1000 , reason ) => {
189
+ if ( ! wsRef . value )
190
+ return
191
+ explicitlyClosed = true
192
+ resetHeartbeat ( )
193
+ heartbeatPause ?.( )
194
+ wsRef . value . close ( code , reason )
195
+ }
196
+
196
197
const send = ( data : string | ArrayBuffer | Blob , useBuffer = true ) => {
197
198
if ( ! wsRef . value || status . value !== 'OPEN' ) {
198
199
if ( useBuffer )
You can’t perform that action at this time.
0 commit comments