File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
packages/core/useWebSocket Expand file tree Collapse file tree 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>(
171171
172172 let pongTimeoutWait : ReturnType < typeof setTimeout > | undefined
173173
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-
183174 const _sendBuffer = ( ) => {
184175 if ( bufferedData . length && wsRef . value && status . value === 'OPEN' ) {
185176 for ( const buffer of bufferedData )
@@ -193,6 +184,16 @@ export function useWebSocket<Data = any>(
193184 pongTimeoutWait = undefined
194185 }
195186
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+
196197 const send = ( data : string | ArrayBuffer | Blob , useBuffer = true ) => {
197198 if ( ! wsRef . value || status . value !== 'OPEN' ) {
198199 if ( useBuffer )
You can’t perform that action at this time.
0 commit comments