Skip to content

Commit

Permalink
fix(client): reconnection bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
st-vi committed Dec 12, 2023
1 parent 0289bad commit fde0f2a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions WebSocketClient/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ const createUrl = (hostname: string, port: number, path: string, searchParams: R

const createWebSocket = (url: string): WebSocket => {
const webSocket = new WebSocket(url);

webSocket.onerror = () => {
if(connectionText){
displayEditorError( "Could not connect to language server. Reconnecting ...");
}
if(languageClient !== undefined && languageClient.isRunning()){
//languageClient.dispose();
}
setTimeout(() => {
createWebSocket(url);
}, 1000);
}, 500);
};
webSocket.onopen = () => {
if(connectionText){
Expand All @@ -82,15 +86,24 @@ const createWebSocket = (url: string): WebSocket => {

languageClient.start();
reader.onClose(() => {
languageClient.stop();
createWebSocket(url);
if(languageClient !== undefined && languageClient.isRunning()){
//languageClient.dispose();
}
setTimeout(() => {
createWebSocket(url);
}, 500);
});
};
/*
webSocket.onclose = () => {
if(languageClient !== undefined && languageClient.isRunning()){
languageClient.dispose();
}
setTimeout(() => {
createWebSocket(url);
}, 500);
}
*/
return webSocket;
};

Expand Down

0 comments on commit fde0f2a

Please sign in to comment.