| 
				
			 | 
			
			
				
				@@ -1,7 +1,7 @@ 
			 | 
		
		
	
		
			
			| 
				1
			 | 
			
				1
			 | 
			
			
				
				 import { describe, it } from "mocha"; 
			 | 
		
		
	
		
			
			| 
				2
			 | 
			
				2
			 | 
			
			
				
				 import { RPCServer, RPCSocket, Serializable } from '../Index' 
			 | 
		
		
	
		
			
			| 
				3
			 | 
			
				3
			 | 
			
			
				
				 import { RPCExporter, Socket } from "../src/Interfaces"; 
			 | 
		
		
	
		
			
			| 
				4
			 | 
			
				
			 | 
			
			
				
				-import { ConnectedSocket, Callback } from "../src/Types"; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				4
			 | 
			
			
				
				+import { ConnectedSocket, Callback, GenericFunction } from "../src/Types"; 
			 | 
		
		
	
		
			
			| 
				5
			 | 
			
				5
			 | 
			
			
				
				 import * as log from 'why-is-node-running'; 
			 | 
		
		
	
		
			
			| 
				6
			 | 
			
				6
			 | 
			
			
				
				 import * as http from 'http'; 
			 | 
		
		
	
		
			
			| 
				7
			 | 
			
				7
			 | 
			
			
				
				 import * as express from 'express'; 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -9,11 +9,11 @@ import * as fetch from 'node-fetch'; 
			 | 
		
		
	
		
			
			| 
				9
			 | 
			
				9
			 | 
			
			
				
				 import { PromiseIO } from "../src/PromiseIO/Server"; 
			 | 
		
		
	
		
			
			| 
				10
			 | 
			
				10
			 | 
			
			
				
				 import { PromiseIOClient } from "../src/PromiseIO/Client"; 
			 | 
		
		
	
		
			
			| 
				11
			 | 
			
				11
			 | 
			
			
				
				 import { assert, expect } from 'chai'; 
			 | 
		
		
	
		
			
			| 
				12
			 | 
			
				
			 | 
			
			
				
				-import { USER_DEFINED_TIMEOUT } from "../src/Strings"; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				12
			 | 
			
			
				
				+import { CLASSNAME_ATTRIBUTE, USER_DEFINED_TIMEOUT } from "../src/Strings"; 
			 | 
		
		
	
		
			
			| 
				13
			 | 
			
				13
			 | 
			
			
				
				 var should = require('chai').should(); 
			 | 
		
		
	
		
			
			| 
				14
			 | 
			
				14
			 | 
			
			
				
				 var chai = require("chai"); 
			 | 
		
		
	
		
			
			| 
				15
			 | 
			
				15
			 | 
			
			
				
				 var chaiAsPromised = require("chai-as-promised"); 
			 | 
		
		
	
		
			
			| 
				16
			 | 
			
				
			 | 
			
			
				
				-  
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				16
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				17
			 | 
			
				17
			 | 
			
			
				
				 chai.use(chaiAsPromised); 
			 | 
		
		
	
		
			
			| 
				18
			 | 
			
				18
			 | 
			
			
				
				 const noop = (...args) => { } 
			 | 
		
		
	
		
			
			| 
				19
			 | 
			
				19
			 | 
			
			
				
				  
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -489,12 +489,12 @@ describe('RPCSocket', () => { 
			 | 
		
		
	
		
			
			| 
				489
			 | 
			
				489
			 | 
			
			
				
				     }) 
			 | 
		
		
	
		
			
			| 
				490
			 | 
			
				490
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				491
			 | 
			
				491
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				492
			 | 
			
				
			 | 
			
			
				
				-    it('should have rpc echo', async() => { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				492
			 | 
			
			
				
				+    it('should have rpc echo', async () => { 
			 | 
		
		
	
		
			
			| 
				493
			 | 
			
				493
			 | 
			
			
				
				         const x = await client['test'].echo("x") 
			 | 
		
		
	
		
			
			| 
				494
			 | 
			
				494
			 | 
			
			
				
				         expect(x).to.be.equal('x') 
			 | 
		
		
	
		
			
			| 
				495
			 | 
			
				495
			 | 
			
			
				
				     }) 
			 | 
		
		
	
		
			
			| 
				496
			 | 
			
				496
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				497
			 | 
			
				
			 | 
			
			
				
				-    it('should add up to 6', async() => { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				497
			 | 
			
			
				
				+    it('should add up to 6', async () => { 
			 | 
		
		
	
		
			
			| 
				498
			 | 
			
				498
			 | 
			
			
				
				         const sum = await client['test'].add(1, 2, 3) 
			 | 
		
		
	
		
			
			| 
				499
			 | 
			
				499
			 | 
			
			
				
				         expect(sum).to.be.equal(6) 
			 | 
		
		
	
		
			
			| 
				500
			 | 
			
				500
			 | 
			
			
				
				     }) 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -590,7 +590,7 @@ describe('It should do unhook', () => { 
			 | 
		
		
	
		
			
			| 
				590
			 | 
			
				590
			 | 
			
			
				
				     let run = 0 
			 | 
		
		
	
		
			
			| 
				591
			 | 
			
				591
			 | 
			
			
				
				     const expected = [yesCandy, noCandy, noCandy, noCandy] 
			 | 
		
		
	
		
			
			| 
				592
			 | 
			
				592
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				593
			 | 
			
				
			 | 
			
			
				
				-    it('Unhook+unsubscribe should stop callbacks', async() => { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				593
			 | 
			
			
				
				+    it('Unhook+unsubscribe should stop callbacks', async () => { 
			 | 
		
		
	
		
			
			| 
				594
			 | 
			
				594
			 | 
			
			
				
				         await client['test'].subscribe(function myCallback(c) { 
			 | 
		
		
	
		
			
			| 
				595
			 | 
			
				595
			 | 
			
			
				
				             if (run == 1) 
			 | 
		
		
	
		
			
			| 
				596
			 | 
			
				596
			 | 
			
			
				
				                 (myCallback as any).destroy() 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -614,7 +614,7 @@ type topicDTO = { topic: string; } 
			 | 
		
		
	
		
			
			| 
				614
			 | 
			
				614
			 | 
			
			
				
				 type SesameTestIfc = { 
			 | 
		
		
	
		
			
			| 
				615
			 | 
			
				615
			 | 
			
			
				
				     test: { 
			 | 
		
		
	
		
			
			| 
				616
			 | 
			
				616
			 | 
			
			
				
				         checkCandy: () => Promise<string> 
			 | 
		
		
	
		
			
			| 
				617
			 | 
			
				
			 | 
			
			
				
				-        subscribe: (callback: Callback<string>) => Promise<topicDTO> 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				617
			 | 
			
			
				
				+        subscribe: (callback: Callback<[string]>) => Promise<topicDTO> 
			 | 
		
		
	
		
			
			| 
				618
			 | 
			
				618
			 | 
			
			
				
				         manyParams: <A = string, B = number, C = boolean, D = Object>(a: A, b: B, c: C, d: D) => Promise<[A, B, C, D]> 
			 | 
		
		
	
		
			
			| 
				619
			 | 
			
				619
			 | 
			
			
				
				     } 
			 | 
		
		
	
		
			
			| 
				620
			 | 
			
				620
			 | 
			
			
				
				 } 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -688,7 +688,7 @@ describe('Sesame should unlock the socket', () => { 
			 | 
		
		
	
		
			
			| 
				688
			 | 
			
				688
			 | 
			
			
				
				     }) 
			 | 
		
		
	
		
			
			| 
				689
			 | 
			
				689
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				690
			 | 
			
				690
			 | 
			
			
				
				     it('callback should work with sesame', (done) => { 
			 | 
		
		
	
		
			
			| 
				691
			 | 
			
				
			 | 
			
			
				
				-        client.test.subscribe(function(c){ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				691
			 | 
			
			
				
				+        client.test.subscribe(function (c) { 
			 | 
		
		
	
		
			
			| 
				692
			 | 
			
				692
			 | 
			
			
				
				             if (c === candy) { 
			 | 
		
		
	
		
			
			| 
				693
			 | 
			
				693
			 | 
			
			
				
				                 done() 
			 | 
		
		
	
		
			
			| 
				694
			 | 
			
				694
			 | 
			
			
				
				             } 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -725,21 +725,21 @@ describe('Error handling', () => { 
			 | 
		
		
	
		
			
			| 
				725
			 | 
			
				725
			 | 
			
			
				
				                 a: 'a', 
			 | 
		
		
	
		
			
			| 
				726
			 | 
			
				726
			 | 
			
			
				
				                 b: 'b' 
			 | 
		
		
	
		
			
			| 
				727
			 | 
			
				727
			 | 
			
			
				
				             }) 
			 | 
		
		
	
		
			
			| 
				728
			 | 
			
				
			 | 
			
			
				
				-            .then(r => { 
			 | 
		
		
	
		
			
			| 
				729
			 | 
			
				
			 | 
			
			
				
				-                if (r != null) 
			 | 
		
		
	
		
			
			| 
				730
			 | 
			
				
			 | 
			
			
				
				-                    done(new Error("UNEXPECTED RESULT " + r)) 
			 | 
		
		
	
		
			
			| 
				731
			 | 
			
				
			 | 
			
			
				
				-            }) 
			 | 
		
		
	
		
			
			| 
				732
			 | 
			
				
			 | 
			
			
				
				-            .catch((e) => { 
			 | 
		
		
	
		
			
			| 
				733
			 | 
			
				
			 | 
			
			
				
				-                if (e.message === errtxt) 
			 | 
		
		
	
		
			
			| 
				734
			 | 
			
				
			 | 
			
			
				
				-                    done() 
			 | 
		
		
	
		
			
			| 
				735
			 | 
			
				
			 | 
			
			
				
				-                else 
			 | 
		
		
	
		
			
			| 
				736
			 | 
			
				
			 | 
			
			
				
				-                    done(e) 
			 | 
		
		
	
		
			
			| 
				737
			 | 
			
				
			 | 
			
			
				
				-            }) 
			 | 
		
		
	
		
			
			| 
				738
			 | 
			
				
			 | 
			
			
				
				-            .finally(() => { 
			 | 
		
		
	
		
			
			| 
				739
			 | 
			
				
			 | 
			
			
				
				-                cli.close() 
			 | 
		
		
	
		
			
			| 
				740
			 | 
			
				
			 | 
			
			
				
				-                sock.close() 
			 | 
		
		
	
		
			
			| 
				741
			 | 
			
				
			 | 
			
			
				
				-                server.close() 
			 | 
		
		
	
		
			
			| 
				742
			 | 
			
				
			 | 
			
			
				
				-            }) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				728
			 | 
			
			
				
				+                .then(r => { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				729
			 | 
			
			
				
				+                    if (r != null) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				730
			 | 
			
			
				
				+                        done(new Error("UNEXPECTED RESULT " + r)) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				731
			 | 
			
			
				
				+                }) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				732
			 | 
			
			
				
				+                .catch((e) => { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				733
			 | 
			
			
				
				+                    if (e.message === errtxt) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				734
			 | 
			
			
				
				+                        done() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				735
			 | 
			
			
				
				+                    else 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				736
			 | 
			
			
				
				+                        done(e) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				737
			 | 
			
			
				
				+                }) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				738
			 | 
			
			
				
				+                .finally(() => { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				739
			 | 
			
			
				
				+                    cli.close() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				740
			 | 
			
			
				
				+                    sock.close() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				741
			 | 
			
			
				
				+                    server.close() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				742
			 | 
			
			
				
				+                }) 
			 | 
		
		
	
		
			
			| 
				743
			 | 
			
				743
			 | 
			
			
				
				         }) 
			 | 
		
		
	
		
			
			| 
				744
			 | 
			
				744
			 | 
			
			
				
				     }) 
			 | 
		
		
	
		
			
			| 
				745
			 | 
			
				745
			 | 
			
			
				
				  
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -1014,12 +1014,12 @@ describe("attaching handlers before connecting", () => { 
			 | 
		
		
	
		
			
			| 
				1014
			 | 
			
				1014
			 | 
			
			
				
				 describe("class (de-)serialization", () => { 
			 | 
		
		
	
		
			
			| 
				1015
			 | 
			
				1015
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				1016
			 | 
			
				1016
			 | 
			
			
				
				     @Serializable() 
			 | 
		
		
	
		
			
			| 
				1017
			 | 
			
				
			 | 
			
			
				
				-    class SubClass{ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1017
			 | 
			
			
				
				+    class SubClass { 
			 | 
		
		
	
		
			
			| 
				1018
			 | 
			
				1018
			 | 
			
			
				
				         fString = "F" 
			 | 
		
		
	
		
			
			| 
				1019
			 | 
			
				1019
			 | 
			
			
				
				     } 
			 | 
		
		
	
		
			
			| 
				1020
			 | 
			
				1020
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				1021
			 | 
			
				1021
			 | 
			
			
				
				     @Serializable() 
			 | 
		
		
	
		
			
			| 
				1022
			 | 
			
				
			 | 
			
			
				
				-    class TestClass{ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1022
			 | 
			
			
				
				+    class TestClass { 
			 | 
		
		
	
		
			
			| 
				1023
			 | 
			
				1023
			 | 
			
			
				
				         aString = "A" 
			 | 
		
		
	
		
			
			| 
				1024
			 | 
			
				1024
			 | 
			
			
				
				         aNumber = 46 
			 | 
		
		
	
		
			
			| 
				1025
			 | 
			
				1025
			 | 
			
			
				
				         aObject = { 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -1029,39 +1029,12 @@ describe("class (de-)serialization", () => { 
			 | 
		
		
	
		
			
			| 
				1029
			 | 
			
				1029
			 | 
			
			
				
				         } 
			 | 
		
		
	
		
			
			| 
				1030
			 | 
			
				1030
			 | 
			
			
				
				         aClassObject = new SubClass() 
			 | 
		
		
	
		
			
			| 
				1031
			 | 
			
				1031
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				1032
			 | 
			
				
			 | 
			
			
				
				-        public returnOK(){ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1032
			 | 
			
			
				
				+        public returnOK() { 
			 | 
		
		
	
		
			
			| 
				1033
			 | 
			
				1033
			 | 
			
			
				
				             return "OK" 
			 | 
		
		
	
		
			
			| 
				1034
			 | 
			
				1034
			 | 
			
			
				
				         } 
			 | 
		
		
	
		
			
			| 
				1035
			 | 
			
				1035
			 | 
			
			
				
				     } 
			 | 
		
		
	
		
			
			| 
				1036
			 | 
			
				1036
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				1037
			 | 
			
				
			 | 
			
			
				
				-    let myServer: RPCServer; 
			 | 
		
		
	
		
			
			| 
				1038
			 | 
			
				
			 | 
			
			
				
				-    let mySocket: RPCSocket; 
			 | 
		
		
	
		
			
			| 
				1039
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				1040
			 | 
			
				
			 | 
			
			
				
				-    before(function(done){ 
			 | 
		
		
	
		
			
			| 
				1041
			 | 
			
				
			 | 
			
			
				
				-        myServer = new RPCServer([{ 
			 | 
		
		
	
		
			
			| 
				1042
			 | 
			
				
			 | 
			
			
				
				-            name: "Test", 
			 | 
		
		
	
		
			
			| 
				1043
			 | 
			
				
			 | 
			
			
				
				-            RPCs: [ 
			 | 
		
		
	
		
			
			| 
				1044
			 | 
			
				
			 | 
			
			
				
				-                function returnClass(){ 
			 | 
		
		
	
		
			
			| 
				1045
			 | 
			
				
			 | 
			
			
				
				-                    return new TestClass() 
			 | 
		
		
	
		
			
			| 
				1046
			 | 
			
				
			 | 
			
			
				
				-                } 
			 | 
		
		
	
		
			
			| 
				1047
			 | 
			
				
			 | 
			
			
				
				-            ] 
			 | 
		
		
	
		
			
			| 
				1048
			 | 
			
				
			 | 
			
			
				
				-        }]) 
			 | 
		
		
	
		
			
			| 
				1049
			 | 
			
				
			 | 
			
			
				
				-        myServer.listen(8084) 
			 | 
		
		
	
		
			
			| 
				1050
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				1051
			 | 
			
				
			 | 
			
			
				
				-        mySocket = new RPCSocket(8084, 'localhost') 
			 | 
		
		
	
		
			
			| 
				1052
			 | 
			
				
			 | 
			
			
				
				-        mySocket.connect().then(() => done()) 
			 | 
		
		
	
		
			
			| 
				1053
			 | 
			
				
			 | 
			
			
				
				-    }) 
			 | 
		
		
	
		
			
			| 
				1054
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				1055
			 | 
			
				
			 | 
			
			
				
				-    after(function(done){ 
			 | 
		
		
	
		
			
			| 
				1056
			 | 
			
				
			 | 
			
			
				
				-        mySocket.close() 
			 | 
		
		
	
		
			
			| 
				1057
			 | 
			
				
			 | 
			
			
				
				-        myServer.close() 
			 | 
		
		
	
		
			
			| 
				1058
			 | 
			
				
			 | 
			
			
				
				-        done() 
			 | 
		
		
	
		
			
			| 
				1059
			 | 
			
				
			 | 
			
			
				
				-    }) 
			 | 
		
		
	
		
			
			| 
				1060
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				1061
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				1062
			 | 
			
				
			 | 
			
			
				
				-    it("receives class in call response", async () => { 
			 | 
		
		
	
		
			
			| 
				1063
			 | 
			
				
			 | 
			
			
				
				-        const obj: TestClass = await mySocket['Test'].returnClass() 
			 | 
		
		
	
		
			
			| 
				1064
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1037
			 | 
			
			
				
				+    const verifyObject = (obj: any) => { 
			 | 
		
		
	
		
			
			| 
				1065
			 | 
			
				1038
			 | 
			
			
				
				         expect(obj).to.be.an.instanceOf(TestClass) 
			 | 
		
		
	
		
			
			| 
				1066
			 | 
			
				1039
			 | 
			
			
				
				         expect(obj.aString).to.be.a('string') 
			 | 
		
		
	
		
			
			| 
				1067
			 | 
			
				1040
			 | 
			
			
				
				         expect(obj.aNumber).to.be.a('number') 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -1070,22 +1043,90 @@ describe("class (de-)serialization", () => { 
			 | 
		
		
	
		
			
			| 
				1070
			 | 
			
				1043
			 | 
			
			
				
				         expect(obj.aObject.y).to.be.undefined 
			 | 
		
		
	
		
			
			| 
				1071
			 | 
			
				1044
			 | 
			
			
				
				         expect(obj.aObject.sub).to.be.an.instanceOf(SubClass) 
			 | 
		
		
	
		
			
			| 
				1072
			 | 
			
				1045
			 | 
			
			
				
				         expect(obj.aClassObject).to.be.an.instanceOf(SubClass) 
			 | 
		
		
	
		
			
			| 
				1073
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1046
			 | 
			
			
				
				+        expect(obj).to.not.have.key(CLASSNAME_ATTRIBUTE) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1047
			 | 
			
			
				
				+        expect(obj.aObject.sub).to.not.have.key(CLASSNAME_ATTRIBUTE) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1048
			 | 
			
			
				
				+        expect(obj.aClassObject).to.not.have.key(CLASSNAME_ATTRIBUTE) 
			 | 
		
		
	
		
			
			| 
				1074
			 | 
			
				1049
			 | 
			
			
				
				         expect(obj.returnOK()).to.be.equal('OK') 
			 | 
		
		
	
		
			
			| 
				1075
			 | 
			
				
			 | 
			
			
				
				-    }) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1050
			 | 
			
			
				
				+    } 
			 | 
		
		
	
		
			
			| 
				1076
			 | 
			
				1051
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				1077
			 | 
			
				
			 | 
			
			
				
				-    it("receives class in hook response", async () => { 
			 | 
		
		
	
		
			
			| 
				1078
			 | 
			
				
			 | 
			
			
				
				-        const obj: TestClass = await mySocket['Test'].returnClass() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1052
			 | 
			
			
				
				+    describe("Responses", () => { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1053
			 | 
			
			
				
				+        type TestIfc = { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1054
			 | 
			
			
				
				+            Test: { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1055
			 | 
			
			
				
				+                returnClass: () => Promise<TestClass> 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1056
			 | 
			
			
				
				+                classCallback: (callback: Callback<[TestClass]>) => Promise<TestClass> 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1057
			 | 
			
			
				
				+            } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1058
			 | 
			
			
				
				+        } 
			 | 
		
		
	
		
			
			| 
				1079
			 | 
			
				1059
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				1080
			 | 
			
				
			 | 
			
			
				
				-        expect(obj).to.be.an.instanceOf(TestClass) 
			 | 
		
		
	
		
			
			| 
				1081
			 | 
			
				
			 | 
			
			
				
				-        expect(obj.aString).to.be.a('string') 
			 | 
		
		
	
		
			
			| 
				1082
			 | 
			
				
			 | 
			
			
				
				-        expect(obj.aNumber).to.be.a('number') 
			 | 
		
		
	
		
			
			| 
				1083
			 | 
			
				
			 | 
			
			
				
				-        expect(obj.aObject).to.be.a('object') 
			 | 
		
		
	
		
			
			| 
				1084
			 | 
			
				
			 | 
			
			
				
				-        expect(obj.aObject.x).to.be.a('string') 
			 | 
		
		
	
		
			
			| 
				1085
			 | 
			
				
			 | 
			
			
				
				-        expect(obj.aObject.y).to.be.undefined 
			 | 
		
		
	
		
			
			| 
				1086
			 | 
			
				
			 | 
			
			
				
				-        expect(obj.aObject.sub).to.be.an.instanceOf(SubClass) 
			 | 
		
		
	
		
			
			| 
				1087
			 | 
			
				
			 | 
			
			
				
				-        expect(obj.aClassObject).to.be.an.instanceOf(SubClass) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1060
			 | 
			
			
				
				+        let myServer: RPCServer<TestIfc>; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1061
			 | 
			
			
				
				+        let mySocket: ConnectedSocket<TestIfc>; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1062
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1063
			 | 
			
			
				
				+        before(function (done) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1064
			 | 
			
			
				
				+            myServer = new RPCServer<TestIfc>([{ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1065
			 | 
			
			
				
				+                name: "Test", 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1066
			 | 
			
			
				
				+                RPCs: [ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1067
			 | 
			
			
				
				+                    async function returnClass() { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1068
			 | 
			
			
				
				+                        return new TestClass() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1069
			 | 
			
			
				
				+                    }, { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1070
			 | 
			
			
				
				+                        name: "classCallback", 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1071
			 | 
			
			
				
				+                        hook: async function (callback) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1072
			 | 
			
			
				
				+                            setTimeout(_ => callback(new TestClass()), 250) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1073
			 | 
			
			
				
				+                            return new TestClass() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1074
			 | 
			
			
				
				+                        } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1075
			 | 
			
			
				
				+                    } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1076
			 | 
			
			
				
				+                ] 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1077
			 | 
			
			
				
				+            }]) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1078
			 | 
			
			
				
				+            myServer.listen(8084) 
			 | 
		
		
	
		
			
			| 
				1088
			 | 
			
				1079
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				1089
			 | 
			
				
			 | 
			
			
				
				-        expect(obj.returnOK()).to.be.equal('OK') 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1080
			 | 
			
			
				
				+            new RPCSocket<TestIfc>(8084, 'localhost').connect().then(connsock => { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1081
			 | 
			
			
				
				+                mySocket = connsock 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1082
			 | 
			
			
				
				+                done() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1083
			 | 
			
			
				
				+            }) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1084
			 | 
			
			
				
				+        }) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1085
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1086
			 | 
			
			
				
				+        after(function (done) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1087
			 | 
			
			
				
				+            mySocket.close() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1088
			 | 
			
			
				
				+            myServer.close() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1089
			 | 
			
			
				
				+            done() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1090
			 | 
			
			
				
				+        }) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1091
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1092
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1093
			 | 
			
			
				
				+        it("receives class object in call response", async () => { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1094
			 | 
			
			
				
				+            const obj: TestClass = await mySocket['Test'].returnClass() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1095
			 | 
			
			
				
				+            verifyObject(obj) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1096
			 | 
			
			
				
				+        }) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1097
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1098
			 | 
			
			
				
				+        it("receives class object in hook response", async function () { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1099
			 | 
			
			
				
				+            const obj: TestClass = await mySocket.Test.classCallback(noop) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1100
			 | 
			
			
				
				+            verifyObject(obj) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1101
			 | 
			
			
				
				+        }) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1102
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1103
			 | 
			
			
				
				+        it("receives class object in callback", function (done) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1104
			 | 
			
			
				
				+            mySocket.Test.classCallback(function (cbValue) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1105
			 | 
			
			
				
				+                verifyObject(cbValue) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1106
			 | 
			
			
				
				+                done() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1107
			 | 
			
			
				
				+            }).then(verifyObject) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1108
			 | 
			
			
				
				+        }) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1109
			 | 
			
			
				
				+    }) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1110
			 | 
			
			
				
				+    describe("Parameters", () => { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1111
			 | 
			
			
				
				+        it("Class object in call", function(done){ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1112
			 | 
			
			
				
				+            const server = new RPCServer([ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1113
			 | 
			
			
				
				+                { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1114
			 | 
			
			
				
				+                    name: "Test", 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1115
			 | 
			
			
				
				+                    RPCs: [ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1116
			 | 
			
			
				
				+                        function callWithClass(testObj: TestClass){ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1117
			 | 
			
			
				
				+                            verifyObject(testObj) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1118
			 | 
			
			
				
				+                            done() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1119
			 | 
			
			
				
				+                        } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1120
			 | 
			
			
				
				+                    ] 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1121
			 | 
			
			
				
				+                } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1122
			 | 
			
			
				
				+            ]).listen(8086) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1123
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1124
			 | 
			
			
				
				+            new RPCSocket(8086, 'localhost').connect().then(sock => { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1125
			 | 
			
			
				
				+                sock['Test'].callWithClass(new TestClass()).then(_ => { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1126
			 | 
			
			
				
				+                    sock.close() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1127
			 | 
			
			
				
				+                    server.close() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1128
			 | 
			
			
				
				+                }) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1129
			 | 
			
			
				
				+            }) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1130
			 | 
			
			
				
				+        }) 
			 | 
		
		
	
		
			
			| 
				1090
			 | 
			
				1131
			 | 
			
			
				
				     }) 
			 | 
		
		
	
		
			
			| 
				1091
			 | 
			
				1132
			 | 
			
			
				
				 }) 
			 |