File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
This example shows how clients can cancel in-flight RPCs by cancelling the
4
4
call object returned by the method invocation. The client will receive a status
5
- with code ` CANCELLED ` and the server handler's call object will emit a
6
- ` 'cancelled' ` event.
5
+ with code ` CANCELLED ` and the server handler's call object will emit either a
6
+ ` 'cancelled' ` event or an ` 'end' ` event .
7
7
8
8
## Start the server
9
9
Original file line number Diff line number Diff line change @@ -38,11 +38,13 @@ function bidirectionalStreamingEcho(call) {
38
38
console . log ( `echoing message "${ message } "` ) ;
39
39
call . write ( { message : message } ) ;
40
40
} ) ;
41
+ // Either 'end' or 'cancelled' will be emitted when the call is cancelled
41
42
call . on ( 'end' , ( ) => {
43
+ console . log ( 'server received end event' )
42
44
call . end ( ) ;
43
45
} ) ;
44
46
call . on ( 'cancelled' , ( ) => {
45
- console . log ( 'received cancelled event' ) ;
47
+ console . log ( 'server received cancelled event' ) ;
46
48
} ) ;
47
49
}
48
50
You can’t perform that action at this time.
0 commit comments