@@ -427,6 +427,27 @@ impl Dispatcher {
427
427
}
428
428
}
429
429
430
+ fn on_foreign_function (
431
+ & self ,
432
+ context_id : u32 ,
433
+ function_id : u32 ,
434
+ arugments_size : usize ,
435
+ ) {
436
+ if let Some ( http_stream) = self . http_streams . borrow_mut ( ) . get_mut ( & context_id) {
437
+ self . active_id . set ( context_id) ;
438
+ hostcalls:: set_effective_context ( context_id) . unwrap ( ) ;
439
+ http_stream. on_foreign_function ( function_id, arugments_size)
440
+ } else if let Some ( stream) = self . streams . borrow_mut ( ) . get_mut ( & context_id) {
441
+ self . active_id . set ( context_id) ;
442
+ hostcalls:: set_effective_context ( context_id) . unwrap ( ) ;
443
+ stream. on_foreign_function ( function_id, arugments_size)
444
+ } else if let Some ( root) = self . roots . borrow_mut ( ) . get_mut ( & context_id) {
445
+ self . active_id . set ( context_id) ;
446
+ hostcalls:: set_effective_context ( context_id) . unwrap ( ) ;
447
+ root. on_foreign_function ( function_id, arugments_size)
448
+ }
449
+ }
450
+
430
451
fn on_grpc_receive_initial_metadata ( & self , token_id : u32 , headers : u32 ) {
431
452
let context_id = match self . grpc_streams . borrow_mut ( ) . get ( & token_id) {
432
453
Some ( id) => * id,
@@ -695,6 +716,17 @@ pub extern "C" fn proxy_on_http_call_response(
695
716
} )
696
717
}
697
718
719
+ #[ no_mangle]
720
+ pub extern "C" fn proxy_on_foreign_function (
721
+ context_id : u32 ,
722
+ function_id : u32 ,
723
+ arguments_size : usize ,
724
+ ) {
725
+ DISPATCHER . with ( |dispatcher| {
726
+ dispatcher. on_foreign_function ( context_id, function_id, arguments_size)
727
+ } )
728
+ }
729
+
698
730
#[ no_mangle]
699
731
pub extern "C" fn proxy_on_grpc_receive_initial_metadata (
700
732
_context_id : u32 ,
0 commit comments