socketio drop in for bsock

This commit is contained in:
2020-07-01 17:53:58 +02:00
parent f5fa51bef5
commit 2a67927306
12 changed files with 781 additions and 151 deletions
+46 -33
View File
@@ -68,8 +68,8 @@ describe('RPCServer', () => {
})
after(done => {
client.destroy()
server.destroy()
client.close()
server.close()
done()
})
@@ -116,8 +116,8 @@ describe('RPCSocket', () => {
})
after(() => {
client.destroy()
server.destroy()
client.close()
server.close()
})
@@ -221,8 +221,8 @@ describe('It should do unhook', () => {
})
after(() => {
client.destroy()
server.destroy()
client.close()
server.close()
})
it('Subscribe with param', (done) => {
@@ -314,8 +314,8 @@ describe('Sesame should unlock the socket', () => {
})
after(() => {
client.destroy()
server.destroy()
client.close()
server.close()
})
it('should work with sesame', (done) => {
@@ -337,8 +337,8 @@ describe('Sesame should unlock the socket', () => {
else {
done(new Error("Function supposed to be removed without sesame"))
}
cli.destroy()
sock.destroy()
cli.close()
sock.close()
})
})
@@ -350,8 +350,8 @@ describe('Sesame should unlock the socket', () => {
else {
done(new Error("Function supposed to be removed without sesame"))
}
cli.destroy()
sock.destroy()
cli.close()
sock.close()
})
})
@@ -405,9 +405,9 @@ describe('Error handling', () => {
done(e)
})
.finally(() => {
cli.destroy()
sock.destroy()
server.destroy()
cli.close()
sock.close()
server.close()
})
})
})
@@ -440,9 +440,9 @@ describe('Error handling', () => {
done(e)
})
.finally(() => {
cli.destroy()
sock.destroy()
server.destroy()
cli.close()
sock.close()
server.close()
})
})
})
@@ -484,9 +484,9 @@ describe("Errorhandler functionality", () => {
done(new Error("UNEXPECTED CLIENT ERROR " + e.message))
})
.finally(() => {
cli.destroy()
sock.destroy()
server.destroy()
cli.close()
sock.close()
server.close()
})
})
})
@@ -523,9 +523,9 @@ describe("Errorhandler functionality", () => {
done(e)
})
.finally(() => {
cli.destroy()
sock.destroy()
server.destroy()
cli.close()
sock.close()
server.close()
})
})
})
@@ -595,12 +595,12 @@ describe("Class binding", () => {
})
afterEach((done) => {
sock.destroy()
sock.close()
done()
})
after(() => {
serv.destroy()
serv.close()
})
/* The server-side socket will enter a 30s timeout if destroyed by a RPC.
@@ -663,26 +663,38 @@ describe("attaching handlers before connecting", () => {
}).catch(e => {
//catch clause fires second
if (errorHandleCount != 1) {
console.log("catch clause didn't fire second");
console.log("catch clause didn't fire second", errorHandleCount);
} else {
sock.destroy()
sock.close()
done()
}
})
})
/*
* ## 1.11.0 breaking ##
*
* API change: Move from bsock to socketio changes underlying API for when errors are thrown.
* socketio does not throw on unknown listener. This behaviour is considered more consistent with the design
* goals of RPClibrary and was thus adopted
*
it("fires error if call is unknown", (done) => {
const serv = new RPCServer(21004)
const sock = new RPCSocket(21004, 'localhost')
sock.on('error', (err) => {
sock.destroy()
serv.destroy()
sock.close()
serv.close()
done()
})
sock.connect().then(_ => {
sock.call("unknownRPC123", "AAAAA").catch(e => { /* ignore */ })
sock.call("unknownRPC123", "AAAAA").catch(e => { }).then(x => {
console.log("X",x);
})
}).catch(e => {
console.log("unexpected connect catch clause");
done(e)
@@ -695,8 +707,8 @@ describe("attaching handlers before connecting", () => {
sock.connect().then(_ => {
sock.call("unknownRPC123", "AAAAA").catch(e => {
sock.destroy()
serv.destroy()
sock.close()
serv.close()
done()
})
}).catch(e => {
@@ -704,6 +716,7 @@ describe("attaching handlers before connecting", () => {
done(e)
})
})
*/
})