private void HandleNewServerRpc(GRPCOpError error, IntPtr batchContextPtr) { try { var ctx = new BatchContextSafeHandleNotOwned(batchContextPtr); if (error != GRPCOpError.GRPC_OP_OK) { // TODO: handle error } var rpcInfo = new NewRpcInfo(ctx.GetServerRpcNewCall(), ctx.GetServerRpcNewMethod()); // after server shutdown, the callback returns with null call if (!rpcInfo.Call.IsInvalid) { newRpcQueue.Add(rpcInfo); } } catch (Exception e) { Console.WriteLine("Caught exception in a native handler: " + e); } }
/// <summary> /// Handles the native callback. /// </summary> private void HandleNewServerRpc(bool success, IntPtr batchContextPtr) { try { var ctx = new BatchContextSafeHandleNotOwned(batchContextPtr); // TODO: handle error CallSafeHandle call = ctx.GetServerRpcNewCall(); string method = ctx.GetServerRpcNewMethod(); // after server shutdown, the callback returns with null call if (!call.IsInvalid) { Task.Run(async () => await InvokeCallHandler(call, method)); } AllowOneRpc(); } catch (Exception e) { Console.WriteLine("Caught exception in a native handler: " + e); } }