Skip to content

Commit

Permalink
Method for Socket disconnection added
Browse files Browse the repository at this point in the history
  • Loading branch information
Snafkin547 committed Mar 28, 2024
1 parent 24c990d commit ede15cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
4 changes: 4 additions & 0 deletions lib/jiff-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,10 @@ function JIFFClient(hostname, computation_id, options) {
}
};

this.disconnect = async function(){
await this.socket.safe_disconnect(true)
}

// Connect when all is done
if (options.autoConnect !== false) {
this.connect();
Expand Down
21 changes: 5 additions & 16 deletions tests/arithmetics/arithmetics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,12 @@ describe('JIFF Arithmetic Operations', () => {
});

afterEach(async () => {
// Shutting Server
await jiffClient1.socket.onclose('io client disconnect')
await jiffClient2.socket.onclose('io client disconnect')
// Shutting down client
await jiffClient1.socket.disconnect()
await jiffClient2.socket.disconnect()

// Shutting down Server
await jiffServer.closeAllSockets();
// jiffServer.freeComputation(computation_id);

// Close the server
// await new Promise((resolve, reject) => {
// server.close((err:string) => {
// if (err) {
// console.error('Error closing server:', err);
// reject(err);
// return;
// }
// resolve(console.log('Server closed'));
// });
// });
});

it('should correctly add 60 + 60 = 120', async () => {
Expand Down

0 comments on commit ede15cc

Please sign in to comment.