add socket close connection code and reason
This commit is contained in:
parent
fa24a8d46a
commit
f2c69516df
3 changed files with 6 additions and 11 deletions
|
|
@ -69,10 +69,10 @@ export default function useWebSockets(
|
|||
messageCallback(event.toString())
|
||||
});
|
||||
|
||||
socket.on("close", (event: WebSocket.CloseEvent) => {
|
||||
socket.on("close", (code: number, reason: string) => {
|
||||
connectionStatusCallback(statusOptions ? statusOptions.closeMessage : "Connection Closed");
|
||||
clearInterval(_connectionCheckInterval);
|
||||
if (!event.wasClean) {
|
||||
if (code !== 1000 || reason !== 'session-logout') {
|
||||
setTimeout(() => {
|
||||
connect(socketUrl, secret), _reconnectTimeout
|
||||
});
|
||||
|
|
@ -86,9 +86,9 @@ export default function useWebSockets(
|
|||
|
||||
}
|
||||
|
||||
const close = () => {
|
||||
const close = (code: number, reason: string) => {
|
||||
if (socket) {
|
||||
socket.close();
|
||||
socket.close(code, reason);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -57,14 +57,14 @@ export function launchSession(platformKey: string) {
|
|||
/* connect to the platform */
|
||||
connect(config.PLATFORM_URL, platformKey);
|
||||
|
||||
// initialize the audio streams
|
||||
// initialize the audio streams
|
||||
// audio.record();
|
||||
|
||||
}
|
||||
|
||||
export function endSession() {
|
||||
|
||||
close();
|
||||
close(1000, 'session-logout');
|
||||
|
||||
uiState.reset();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue