@@ -110,7 +110,7 @@ grpcController.openGrpcConnection = (reqResObj, connectionArray) => {
110110
111111 // Open Connection and set time sent for Unary
112112 reqResObj . connection = 'open' ;
113-
113+
114114 time . timeSent = Date . now ( ) ;
115115 // make Unary call
116116 client [ rpc ] ( query , meta , ( err , data ) => {
@@ -155,11 +155,13 @@ grpcController.openGrpcConnection = (reqResObj, connectionArray) => {
155155 else {
156156 //Close Connection for client Stream
157157 reqResObj . connection = 'closed' ;
158- let curTime = Date . now ( )
158+ let curTime = Date . now ( ) ;
159+ console . log ( 'curTime client stream: ' , curTime ) ;
159160 reqResObj . response . times . forEach ( time => {
160161 time . timeReceived = curTime ;
162+ console . log ( 'time.timeReceived client stream: ' , time . timeReceived ) ;
161163 reqResObj . timeReceived = time . timeReceived ;
162- reqResObj . response . events . push ( time )
164+ // reqResObj.response.times .push(time)
163165
164166 } )
165167 reqResObj . response . events . push ( response )
@@ -186,7 +188,8 @@ grpcController.openGrpcConnection = (reqResObj, connectionArray) => {
186188 reqResObj . connection = 'pending' ;
187189
188190
189- time . timeSent = timeSent
191+ time . timeSent = timeSent ;
192+ console . log ( 'time.timeSent client stream: ' , time . timeSent ) ;
190193 reqResObj . response . times . push ( time )
191194
192195
@@ -206,18 +209,12 @@ grpcController.openGrpcConnection = (reqResObj, connectionArray) => {
206209 call . on ( "data" , resp => {
207210 let time = { } ;
208211 time . timeReceived = Date . now ( ) ;
212+ console . log ( 'time.timeReceived Server Stream: ' , time . timeReceived ) ;
209213 time . timeSent = reqResObj . timeSent ;
210214 // add server response to reqResObj and dispatch to state/store
211215 reqResObj . response . events . push ( resp )
212-
213216 reqResObj . response . times . push ( time )
214-
215-
216- // timesArr.push(Date.now())
217- //console.log('new time pushed: ', timesArr)
218- // console.log('data response server stream',resp)
219- // console.log(reqResObj.response.events)
220-
217+ reqResObj . timeReceived = time . timeReceived ; // overwritten on each call to get the final value
221218
222219 store . default . dispatch ( actions . reqResUpdate ( reqResObj ) ) ;
223220 } )
@@ -229,11 +226,8 @@ grpcController.openGrpcConnection = (reqResObj, connectionArray) => {
229226 // Close Connection for SERVER Stream
230227 reqResObj . connection = 'closed' ;
231228
232- reqResObj . timeReceived = Date . now ( ) ;
233-
234- // reqResObj.connectionType = 'plain';
235- // reqResObj.timeReceived =Date.now();
236- // reqResObj.timesArr = timesArr
229+ // reqResObj.timeReceived = Date.now();
230+ // console.log('reqResObj.timeReceived Server Stream: ', reqResObj.timeReceived);
237231
238232 // no need to push response to reqResObj, no event expected from on 'end'
239233 store . default . dispatch ( actions . reqResUpdate ( reqResObj ) ) ;
@@ -260,6 +254,8 @@ grpcController.openGrpcConnection = (reqResObj, connectionArray) => {
260254 reqResObj . connection = 'pending' ;
261255 curTimeObj . timeReceived = Date . now ( ) ;
262256 reqResObj . timeReceived = curTimeObj . timeReceived ;
257+ console . log ( 'curTimeObj.timeReceived BIDI on data: ' , curTimeObj . timeReceived ) ;
258+ console . log ( 'reqResObj.timeReceived BIDI on data: ' , reqResObj . timeReceived ) ;
263259 reqResObj . response . events . push ( response ) ;
264260 reqResObj . response . times . push ( curTimeObj ) ;
265261 store . default . dispatch ( actions . reqResUpdate ( reqResObj ) ) ;
@@ -281,7 +277,8 @@ grpcController.openGrpcConnection = (reqResObj, connectionArray) => {
281277 call . on ( 'end' , ( data ) => {
282278 //Close Final Server Connection for BIDIRECTIONAL Stream
283279 reqResObj . connection = 'closed' ;
284- reqResObj . timeReceived = Date . now ( ) ;
280+ // reqResObj.timeReceived = Date.now();
281+ // console.log('reqResObj.timeReceived BIDI on end: ', reqResObj.timeReceived);
285282 // no need to push response to reqResObj, no event expected from on 'end'
286283 store . default . dispatch ( actions . reqResUpdate ( reqResObj ) ) ;
287284 } ) ;
@@ -296,14 +293,17 @@ grpcController.openGrpcConnection = (reqResObj, connectionArray) => {
296293 reqResObj . connection = 'pending' ;
297294 }
298295 time . timeSent = Date . now ( ) ;
296+ console . log ( 'time.timeSent open connection for BIDI: ' , time . timeSent ) ;
299297 reqResObj . timeSent = time . timeSent ;
298+ console . log ( 'reqResObj.timeSent open connection for BIDI: ' , reqResObj . timeSent ) ;
300299 reqResObj . response . times . push ( time )
301300 call . write ( query ) ;
302301 }
303302 call . end ( ) ;
304303 }
305- reqResObj . connection = 'closed' ;
306- reqResObj . timeReceived = Date . now ( ) ;
304+ // reqResObj.connection = 'closed';
305+ // reqResObj.timeReceived = Date.now();
306+ // console.log('reqResObj.timeReceived end of controller unspecified: ', reqResObj.timeReceived);
307307 store . default . dispatch ( actions . reqResUpdate ( reqResObj ) ) ;
308308} ;
309309export default grpcController ;
0 commit comments