예제 #1
0
        /// <summary>
        /// Handles the native callback.
        /// </summary>
        private void HandleNewServerRpc(GRPCOpError error, IntPtr batchContextPtr)
        {
            try
            {
                var ctx = new BatchContextSafeHandleNotOwned(batchContextPtr);

                if (error != GRPCOpError.GRPC_OP_OK)
                {
                    // 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);
            }
        }
예제 #2
0
파일: Server.cs 프로젝트: zhangf911/grpc
        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);
            }
        }