Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 1 | #region Copyright notice and license |
| 2 | |
Craig Tiller | 6169d5f | 2016-03-31 07:46:18 -0700 | [diff] [blame] | 3 | // Copyright 2015, Google Inc. |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 4 | // All rights reserved. |
| 5 | // |
| 6 | // Redistribution and use in source and binary forms, with or without |
| 7 | // modification, are permitted provided that the following conditions are |
| 8 | // met: |
| 9 | // |
| 10 | // * Redistributions of source code must retain the above copyright |
| 11 | // notice, this list of conditions and the following disclaimer. |
| 12 | // * Redistributions in binary form must reproduce the above |
| 13 | // copyright notice, this list of conditions and the following disclaimer |
| 14 | // in the documentation and/or other materials provided with the |
| 15 | // distribution. |
| 16 | // * Neither the name of Google Inc. nor the names of its |
| 17 | // contributors may be used to endorse or promote products derived from |
| 18 | // this software without specific prior written permission. |
| 19 | // |
| 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | |
| 32 | #endregion |
| 33 | |
| 34 | using System; |
| 35 | using System.Collections.Concurrent; |
| 36 | using System.Diagnostics; |
| 37 | using System.IO; |
| 38 | using System.Reflection; |
| 39 | using System.Runtime.InteropServices; |
| 40 | using System.Threading; |
| 41 | |
| 42 | using Grpc.Core.Logging; |
| 43 | using Grpc.Core.Utils; |
| 44 | |
| 45 | namespace Grpc.Core.Internal |
| 46 | { |
| 47 | /// <summary> |
| 48 | /// Provides access to all native methods provided by <c>NativeExtension</c>. |
| 49 | /// An extra level of indirection is added to P/Invoke calls to allow intelligent loading |
| 50 | /// of the right configuration of the native extension based on current platform, architecture etc. |
| 51 | /// </summary> |
| 52 | internal class NativeMethods |
| 53 | { |
| 54 | #region Native methods |
| 55 | |
| 56 | public readonly Delegates.grpcsharp_init_delegate grpcsharp_init; |
| 57 | public readonly Delegates.grpcsharp_shutdown_delegate grpcsharp_shutdown; |
| 58 | public readonly Delegates.grpcsharp_version_string_delegate grpcsharp_version_string; |
| 59 | |
| 60 | public readonly Delegates.grpcsharp_batch_context_create_delegate grpcsharp_batch_context_create; |
| 61 | public readonly Delegates.grpcsharp_batch_context_recv_initial_metadata_delegate grpcsharp_batch_context_recv_initial_metadata; |
| 62 | public readonly Delegates.grpcsharp_batch_context_recv_message_length_delegate grpcsharp_batch_context_recv_message_length; |
| 63 | public readonly Delegates.grpcsharp_batch_context_recv_message_to_buffer_delegate grpcsharp_batch_context_recv_message_to_buffer; |
| 64 | public readonly Delegates.grpcsharp_batch_context_recv_status_on_client_status_delegate grpcsharp_batch_context_recv_status_on_client_status; |
| 65 | public readonly Delegates.grpcsharp_batch_context_recv_status_on_client_details_delegate grpcsharp_batch_context_recv_status_on_client_details; |
| 66 | public readonly Delegates.grpcsharp_batch_context_recv_status_on_client_trailing_metadata_delegate grpcsharp_batch_context_recv_status_on_client_trailing_metadata; |
| 67 | public readonly Delegates.grpcsharp_batch_context_server_rpc_new_call_delegate grpcsharp_batch_context_server_rpc_new_call; |
| 68 | public readonly Delegates.grpcsharp_batch_context_server_rpc_new_method_delegate grpcsharp_batch_context_server_rpc_new_method; |
| 69 | public readonly Delegates.grpcsharp_batch_context_server_rpc_new_host_delegate grpcsharp_batch_context_server_rpc_new_host; |
| 70 | public readonly Delegates.grpcsharp_batch_context_server_rpc_new_deadline_delegate grpcsharp_batch_context_server_rpc_new_deadline; |
| 71 | public readonly Delegates.grpcsharp_batch_context_server_rpc_new_request_metadata_delegate grpcsharp_batch_context_server_rpc_new_request_metadata; |
| 72 | public readonly Delegates.grpcsharp_batch_context_recv_close_on_server_cancelled_delegate grpcsharp_batch_context_recv_close_on_server_cancelled; |
| 73 | public readonly Delegates.grpcsharp_batch_context_destroy_delegate grpcsharp_batch_context_destroy; |
| 74 | |
| 75 | public readonly Delegates.grpcsharp_composite_call_credentials_create_delegate grpcsharp_composite_call_credentials_create; |
| 76 | public readonly Delegates.grpcsharp_call_credentials_release_delegate grpcsharp_call_credentials_release; |
| 77 | |
| 78 | public readonly Delegates.grpcsharp_call_cancel_delegate grpcsharp_call_cancel; |
| 79 | public readonly Delegates.grpcsharp_call_cancel_with_status_delegate grpcsharp_call_cancel_with_status; |
| 80 | public readonly Delegates.grpcsharp_call_start_unary_delegate grpcsharp_call_start_unary; |
| 81 | public readonly Delegates.grpcsharp_call_start_client_streaming_delegate grpcsharp_call_start_client_streaming; |
| 82 | public readonly Delegates.grpcsharp_call_start_server_streaming_delegate grpcsharp_call_start_server_streaming; |
| 83 | public readonly Delegates.grpcsharp_call_start_duplex_streaming_delegate grpcsharp_call_start_duplex_streaming; |
| 84 | public readonly Delegates.grpcsharp_call_send_message_delegate grpcsharp_call_send_message; |
| 85 | public readonly Delegates.grpcsharp_call_send_close_from_client_delegate grpcsharp_call_send_close_from_client; |
| 86 | public readonly Delegates.grpcsharp_call_send_status_from_server_delegate grpcsharp_call_send_status_from_server; |
| 87 | public readonly Delegates.grpcsharp_call_recv_message_delegate grpcsharp_call_recv_message; |
| 88 | public readonly Delegates.grpcsharp_call_recv_initial_metadata_delegate grpcsharp_call_recv_initial_metadata; |
| 89 | public readonly Delegates.grpcsharp_call_start_serverside_delegate grpcsharp_call_start_serverside; |
| 90 | public readonly Delegates.grpcsharp_call_send_initial_metadata_delegate grpcsharp_call_send_initial_metadata; |
| 91 | public readonly Delegates.grpcsharp_call_set_credentials_delegate grpcsharp_call_set_credentials; |
| 92 | public readonly Delegates.grpcsharp_call_get_peer_delegate grpcsharp_call_get_peer; |
| 93 | public readonly Delegates.grpcsharp_call_destroy_delegate grpcsharp_call_destroy; |
| 94 | |
| 95 | public readonly Delegates.grpcsharp_channel_args_create_delegate grpcsharp_channel_args_create; |
| 96 | public readonly Delegates.grpcsharp_channel_args_set_string_delegate grpcsharp_channel_args_set_string; |
| 97 | public readonly Delegates.grpcsharp_channel_args_set_integer_delegate grpcsharp_channel_args_set_integer; |
| 98 | public readonly Delegates.grpcsharp_channel_args_destroy_delegate grpcsharp_channel_args_destroy; |
| 99 | |
Jan Tattermusch | 660c15b | 2016-02-02 06:39:10 -0800 | [diff] [blame] | 100 | public readonly Delegates.grpcsharp_override_default_ssl_roots grpcsharp_override_default_ssl_roots; |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 101 | public readonly Delegates.grpcsharp_ssl_credentials_create_delegate grpcsharp_ssl_credentials_create; |
| 102 | public readonly Delegates.grpcsharp_composite_channel_credentials_create_delegate grpcsharp_composite_channel_credentials_create; |
| 103 | public readonly Delegates.grpcsharp_channel_credentials_release_delegate grpcsharp_channel_credentials_release; |
| 104 | |
| 105 | public readonly Delegates.grpcsharp_insecure_channel_create_delegate grpcsharp_insecure_channel_create; |
| 106 | public readonly Delegates.grpcsharp_secure_channel_create_delegate grpcsharp_secure_channel_create; |
| 107 | public readonly Delegates.grpcsharp_channel_create_call_delegate grpcsharp_channel_create_call; |
| 108 | public readonly Delegates.grpcsharp_channel_check_connectivity_state_delegate grpcsharp_channel_check_connectivity_state; |
| 109 | public readonly Delegates.grpcsharp_channel_watch_connectivity_state_delegate grpcsharp_channel_watch_connectivity_state; |
| 110 | public readonly Delegates.grpcsharp_channel_get_target_delegate grpcsharp_channel_get_target; |
| 111 | public readonly Delegates.grpcsharp_channel_destroy_delegate grpcsharp_channel_destroy; |
| 112 | |
| 113 | public readonly Delegates.grpcsharp_sizeof_grpc_event_delegate grpcsharp_sizeof_grpc_event; |
| 114 | |
| 115 | public readonly Delegates.grpcsharp_completion_queue_create_delegate grpcsharp_completion_queue_create; |
| 116 | public readonly Delegates.grpcsharp_completion_queue_shutdown_delegate grpcsharp_completion_queue_shutdown; |
| 117 | public readonly Delegates.grpcsharp_completion_queue_next_delegate grpcsharp_completion_queue_next; |
| 118 | public readonly Delegates.grpcsharp_completion_queue_pluck_delegate grpcsharp_completion_queue_pluck; |
| 119 | public readonly Delegates.grpcsharp_completion_queue_destroy_delegate grpcsharp_completion_queue_destroy; |
| 120 | |
| 121 | public readonly Delegates.gprsharp_free_delegate gprsharp_free; |
| 122 | |
| 123 | public readonly Delegates.grpcsharp_metadata_array_create_delegate grpcsharp_metadata_array_create; |
| 124 | public readonly Delegates.grpcsharp_metadata_array_add_delegate grpcsharp_metadata_array_add; |
| 125 | public readonly Delegates.grpcsharp_metadata_array_count_delegate grpcsharp_metadata_array_count; |
| 126 | public readonly Delegates.grpcsharp_metadata_array_get_key_delegate grpcsharp_metadata_array_get_key; |
| 127 | public readonly Delegates.grpcsharp_metadata_array_get_value_delegate grpcsharp_metadata_array_get_value; |
| 128 | public readonly Delegates.grpcsharp_metadata_array_get_value_length_delegate grpcsharp_metadata_array_get_value_length; |
| 129 | public readonly Delegates.grpcsharp_metadata_array_destroy_full_delegate grpcsharp_metadata_array_destroy_full; |
| 130 | |
| 131 | public readonly Delegates.grpcsharp_redirect_log_delegate grpcsharp_redirect_log; |
| 132 | |
| 133 | public readonly Delegates.grpcsharp_metadata_credentials_create_from_plugin_delegate grpcsharp_metadata_credentials_create_from_plugin; |
| 134 | public readonly Delegates.grpcsharp_metadata_credentials_notify_from_plugin_delegate grpcsharp_metadata_credentials_notify_from_plugin; |
| 135 | |
| 136 | public readonly Delegates.grpcsharp_ssl_server_credentials_create_delegate grpcsharp_ssl_server_credentials_create; |
| 137 | public readonly Delegates.grpcsharp_server_credentials_release_delegate grpcsharp_server_credentials_release; |
| 138 | |
| 139 | public readonly Delegates.grpcsharp_server_create_delegate grpcsharp_server_create; |
| 140 | public readonly Delegates.grpcsharp_server_add_insecure_http2_port_delegate grpcsharp_server_add_insecure_http2_port; |
| 141 | public readonly Delegates.grpcsharp_server_add_secure_http2_port_delegate grpcsharp_server_add_secure_http2_port; |
| 142 | public readonly Delegates.grpcsharp_server_start_delegate grpcsharp_server_start; |
| 143 | public readonly Delegates.grpcsharp_server_request_call_delegate grpcsharp_server_request_call; |
| 144 | public readonly Delegates.grpcsharp_server_cancel_all_calls_delegate grpcsharp_server_cancel_all_calls; |
| 145 | public readonly Delegates.grpcsharp_server_shutdown_and_notify_callback_delegate grpcsharp_server_shutdown_and_notify_callback; |
| 146 | public readonly Delegates.grpcsharp_server_destroy_delegate grpcsharp_server_destroy; |
| 147 | |
| 148 | public readonly Delegates.gprsharp_now_delegate gprsharp_now; |
| 149 | public readonly Delegates.gprsharp_inf_future_delegate gprsharp_inf_future; |
| 150 | public readonly Delegates.gprsharp_inf_past_delegate gprsharp_inf_past; |
| 151 | public readonly Delegates.gprsharp_convert_clock_type_delegate gprsharp_convert_clock_type; |
| 152 | public readonly Delegates.gprsharp_sizeof_timespec_delegate gprsharp_sizeof_timespec; |
| 153 | |
| 154 | public readonly Delegates.grpcsharp_test_callback_delegate grpcsharp_test_callback; |
| 155 | public readonly Delegates.grpcsharp_test_nop_delegate grpcsharp_test_nop; |
| 156 | |
| 157 | #endregion |
| 158 | |
| 159 | public NativeMethods(UnmanagedLibrary library) |
| 160 | { |
| 161 | if (PlatformApis.IsLinux || PlatformApis.IsMacOSX) |
| 162 | { |
| 163 | this.grpcsharp_init = GetMethodDelegate<Delegates.grpcsharp_init_delegate>(library); |
| 164 | this.grpcsharp_shutdown = GetMethodDelegate<Delegates.grpcsharp_shutdown_delegate>(library); |
| 165 | this.grpcsharp_version_string = GetMethodDelegate<Delegates.grpcsharp_version_string_delegate>(library); |
| 166 | |
| 167 | this.grpcsharp_batch_context_create = GetMethodDelegate<Delegates.grpcsharp_batch_context_create_delegate>(library); |
| 168 | this.grpcsharp_batch_context_recv_initial_metadata = GetMethodDelegate<Delegates.grpcsharp_batch_context_recv_initial_metadata_delegate>(library); |
| 169 | this.grpcsharp_batch_context_recv_message_length = GetMethodDelegate<Delegates.grpcsharp_batch_context_recv_message_length_delegate>(library); |
| 170 | this.grpcsharp_batch_context_recv_message_to_buffer = GetMethodDelegate<Delegates.grpcsharp_batch_context_recv_message_to_buffer_delegate>(library); |
| 171 | this.grpcsharp_batch_context_recv_status_on_client_status = GetMethodDelegate<Delegates.grpcsharp_batch_context_recv_status_on_client_status_delegate>(library); |
| 172 | this.grpcsharp_batch_context_recv_status_on_client_details = GetMethodDelegate<Delegates.grpcsharp_batch_context_recv_status_on_client_details_delegate>(library); |
| 173 | this.grpcsharp_batch_context_recv_status_on_client_trailing_metadata = GetMethodDelegate<Delegates.grpcsharp_batch_context_recv_status_on_client_trailing_metadata_delegate>(library); |
| 174 | this.grpcsharp_batch_context_server_rpc_new_call = GetMethodDelegate<Delegates.grpcsharp_batch_context_server_rpc_new_call_delegate>(library); |
| 175 | this.grpcsharp_batch_context_server_rpc_new_method = GetMethodDelegate<Delegates.grpcsharp_batch_context_server_rpc_new_method_delegate>(library); |
| 176 | this.grpcsharp_batch_context_server_rpc_new_host = GetMethodDelegate<Delegates.grpcsharp_batch_context_server_rpc_new_host_delegate>(library); |
| 177 | this.grpcsharp_batch_context_server_rpc_new_deadline = GetMethodDelegate<Delegates.grpcsharp_batch_context_server_rpc_new_deadline_delegate>(library); |
| 178 | this.grpcsharp_batch_context_server_rpc_new_request_metadata = GetMethodDelegate<Delegates.grpcsharp_batch_context_server_rpc_new_request_metadata_delegate>(library); |
| 179 | this.grpcsharp_batch_context_recv_close_on_server_cancelled = GetMethodDelegate<Delegates.grpcsharp_batch_context_recv_close_on_server_cancelled_delegate>(library); |
| 180 | this.grpcsharp_batch_context_destroy = GetMethodDelegate<Delegates.grpcsharp_batch_context_destroy_delegate>(library); |
| 181 | |
| 182 | this.grpcsharp_composite_call_credentials_create = GetMethodDelegate<Delegates.grpcsharp_composite_call_credentials_create_delegate>(library); |
| 183 | this.grpcsharp_call_credentials_release = GetMethodDelegate<Delegates.grpcsharp_call_credentials_release_delegate>(library); |
| 184 | |
| 185 | this.grpcsharp_call_cancel = GetMethodDelegate<Delegates.grpcsharp_call_cancel_delegate>(library); |
| 186 | this.grpcsharp_call_cancel_with_status = GetMethodDelegate<Delegates.grpcsharp_call_cancel_with_status_delegate>(library); |
| 187 | this.grpcsharp_call_start_unary = GetMethodDelegate<Delegates.grpcsharp_call_start_unary_delegate>(library); |
| 188 | this.grpcsharp_call_start_client_streaming = GetMethodDelegate<Delegates.grpcsharp_call_start_client_streaming_delegate>(library); |
| 189 | this.grpcsharp_call_start_server_streaming = GetMethodDelegate<Delegates.grpcsharp_call_start_server_streaming_delegate>(library); |
| 190 | this.grpcsharp_call_start_duplex_streaming = GetMethodDelegate<Delegates.grpcsharp_call_start_duplex_streaming_delegate>(library); |
| 191 | this.grpcsharp_call_send_message = GetMethodDelegate<Delegates.grpcsharp_call_send_message_delegate>(library); |
| 192 | this.grpcsharp_call_send_close_from_client = GetMethodDelegate<Delegates.grpcsharp_call_send_close_from_client_delegate>(library); |
| 193 | this.grpcsharp_call_send_status_from_server = GetMethodDelegate<Delegates.grpcsharp_call_send_status_from_server_delegate>(library); |
| 194 | this.grpcsharp_call_recv_message = GetMethodDelegate<Delegates.grpcsharp_call_recv_message_delegate>(library); |
| 195 | this.grpcsharp_call_recv_initial_metadata = GetMethodDelegate<Delegates.grpcsharp_call_recv_initial_metadata_delegate>(library); |
| 196 | this.grpcsharp_call_start_serverside = GetMethodDelegate<Delegates.grpcsharp_call_start_serverside_delegate>(library); |
| 197 | this.grpcsharp_call_send_initial_metadata = GetMethodDelegate<Delegates.grpcsharp_call_send_initial_metadata_delegate>(library); |
| 198 | this.grpcsharp_call_set_credentials = GetMethodDelegate<Delegates.grpcsharp_call_set_credentials_delegate>(library); |
| 199 | this.grpcsharp_call_get_peer = GetMethodDelegate<Delegates.grpcsharp_call_get_peer_delegate>(library); |
| 200 | this.grpcsharp_call_destroy = GetMethodDelegate<Delegates.grpcsharp_call_destroy_delegate>(library); |
| 201 | |
| 202 | this.grpcsharp_channel_args_create = GetMethodDelegate<Delegates.grpcsharp_channel_args_create_delegate>(library); |
| 203 | this.grpcsharp_channel_args_set_string = GetMethodDelegate<Delegates.grpcsharp_channel_args_set_string_delegate>(library); |
| 204 | this.grpcsharp_channel_args_set_integer = GetMethodDelegate<Delegates.grpcsharp_channel_args_set_integer_delegate>(library); |
| 205 | this.grpcsharp_channel_args_destroy = GetMethodDelegate<Delegates.grpcsharp_channel_args_destroy_delegate>(library); |
| 206 | |
Jan Tattermusch | 660c15b | 2016-02-02 06:39:10 -0800 | [diff] [blame] | 207 | this.grpcsharp_override_default_ssl_roots = GetMethodDelegate<Delegates.grpcsharp_override_default_ssl_roots>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 208 | this.grpcsharp_ssl_credentials_create = GetMethodDelegate<Delegates.grpcsharp_ssl_credentials_create_delegate>(library); |
| 209 | this.grpcsharp_composite_channel_credentials_create = GetMethodDelegate<Delegates.grpcsharp_composite_channel_credentials_create_delegate>(library); |
| 210 | this.grpcsharp_channel_credentials_release = GetMethodDelegate<Delegates.grpcsharp_channel_credentials_release_delegate>(library); |
| 211 | |
| 212 | this.grpcsharp_insecure_channel_create = GetMethodDelegate<Delegates.grpcsharp_insecure_channel_create_delegate>(library); |
| 213 | this.grpcsharp_secure_channel_create = GetMethodDelegate<Delegates.grpcsharp_secure_channel_create_delegate>(library); |
| 214 | this.grpcsharp_channel_create_call = GetMethodDelegate<Delegates.grpcsharp_channel_create_call_delegate>(library); |
| 215 | this.grpcsharp_channel_check_connectivity_state = GetMethodDelegate<Delegates.grpcsharp_channel_check_connectivity_state_delegate>(library); |
| 216 | this.grpcsharp_channel_watch_connectivity_state = GetMethodDelegate<Delegates.grpcsharp_channel_watch_connectivity_state_delegate>(library); |
| 217 | this.grpcsharp_channel_get_target = GetMethodDelegate<Delegates.grpcsharp_channel_get_target_delegate>(library); |
| 218 | this.grpcsharp_channel_destroy = GetMethodDelegate<Delegates.grpcsharp_channel_destroy_delegate>(library); |
| 219 | |
| 220 | this.grpcsharp_sizeof_grpc_event = GetMethodDelegate<Delegates.grpcsharp_sizeof_grpc_event_delegate>(library); |
| 221 | |
| 222 | this.grpcsharp_completion_queue_create = GetMethodDelegate<Delegates.grpcsharp_completion_queue_create_delegate>(library); |
| 223 | this.grpcsharp_completion_queue_shutdown = GetMethodDelegate<Delegates.grpcsharp_completion_queue_shutdown_delegate>(library); |
| 224 | this.grpcsharp_completion_queue_next = GetMethodDelegate<Delegates.grpcsharp_completion_queue_next_delegate>(library); |
| 225 | this.grpcsharp_completion_queue_pluck = GetMethodDelegate<Delegates.grpcsharp_completion_queue_pluck_delegate>(library); |
| 226 | this.grpcsharp_completion_queue_destroy = GetMethodDelegate<Delegates.grpcsharp_completion_queue_destroy_delegate>(library); |
| 227 | |
| 228 | this.gprsharp_free = GetMethodDelegate<Delegates.gprsharp_free_delegate>(library); |
| 229 | |
| 230 | this.grpcsharp_metadata_array_create = GetMethodDelegate<Delegates.grpcsharp_metadata_array_create_delegate>(library); |
| 231 | this.grpcsharp_metadata_array_add = GetMethodDelegate<Delegates.grpcsharp_metadata_array_add_delegate>(library); |
| 232 | this.grpcsharp_metadata_array_count = GetMethodDelegate<Delegates.grpcsharp_metadata_array_count_delegate>(library); |
| 233 | this.grpcsharp_metadata_array_get_key = GetMethodDelegate<Delegates.grpcsharp_metadata_array_get_key_delegate>(library); |
| 234 | this.grpcsharp_metadata_array_get_value = GetMethodDelegate<Delegates.grpcsharp_metadata_array_get_value_delegate>(library); |
| 235 | this.grpcsharp_metadata_array_get_value_length = GetMethodDelegate<Delegates.grpcsharp_metadata_array_get_value_length_delegate>(library); |
| 236 | this.grpcsharp_metadata_array_destroy_full = GetMethodDelegate<Delegates.grpcsharp_metadata_array_destroy_full_delegate>(library); |
| 237 | |
| 238 | this.grpcsharp_redirect_log = GetMethodDelegate<Delegates.grpcsharp_redirect_log_delegate>(library); |
| 239 | |
| 240 | this.grpcsharp_metadata_credentials_create_from_plugin = GetMethodDelegate<Delegates.grpcsharp_metadata_credentials_create_from_plugin_delegate>(library); |
| 241 | this.grpcsharp_metadata_credentials_notify_from_plugin = GetMethodDelegate<Delegates.grpcsharp_metadata_credentials_notify_from_plugin_delegate>(library); |
| 242 | |
| 243 | this.grpcsharp_ssl_server_credentials_create = GetMethodDelegate<Delegates.grpcsharp_ssl_server_credentials_create_delegate>(library); |
| 244 | this.grpcsharp_server_credentials_release = GetMethodDelegate<Delegates.grpcsharp_server_credentials_release_delegate>(library); |
| 245 | |
| 246 | this.grpcsharp_server_create = GetMethodDelegate<Delegates.grpcsharp_server_create_delegate>(library); |
| 247 | this.grpcsharp_server_add_insecure_http2_port = GetMethodDelegate<Delegates.grpcsharp_server_add_insecure_http2_port_delegate>(library); |
| 248 | this.grpcsharp_server_add_secure_http2_port = GetMethodDelegate<Delegates.grpcsharp_server_add_secure_http2_port_delegate>(library); |
| 249 | this.grpcsharp_server_start = GetMethodDelegate<Delegates.grpcsharp_server_start_delegate>(library); |
| 250 | this.grpcsharp_server_request_call = GetMethodDelegate<Delegates.grpcsharp_server_request_call_delegate>(library); |
| 251 | this.grpcsharp_server_cancel_all_calls = GetMethodDelegate<Delegates.grpcsharp_server_cancel_all_calls_delegate>(library); |
| 252 | this.grpcsharp_server_shutdown_and_notify_callback = GetMethodDelegate<Delegates.grpcsharp_server_shutdown_and_notify_callback_delegate>(library); |
| 253 | this.grpcsharp_server_destroy = GetMethodDelegate<Delegates.grpcsharp_server_destroy_delegate>(library); |
| 254 | |
| 255 | this.gprsharp_now = GetMethodDelegate<Delegates.gprsharp_now_delegate>(library); |
| 256 | this.gprsharp_inf_future = GetMethodDelegate<Delegates.gprsharp_inf_future_delegate>(library); |
| 257 | this.gprsharp_inf_past = GetMethodDelegate<Delegates.gprsharp_inf_past_delegate>(library); |
| 258 | this.gprsharp_convert_clock_type = GetMethodDelegate<Delegates.gprsharp_convert_clock_type_delegate>(library); |
| 259 | this.gprsharp_sizeof_timespec = GetMethodDelegate<Delegates.gprsharp_sizeof_timespec_delegate>(library); |
| 260 | |
| 261 | this.grpcsharp_test_callback = GetMethodDelegate<Delegates.grpcsharp_test_callback_delegate>(library); |
| 262 | this.grpcsharp_test_nop = GetMethodDelegate<Delegates.grpcsharp_test_nop_delegate>(library); |
| 263 | } |
| 264 | else |
| 265 | { |
| 266 | // Windows or fallback |
| 267 | this.grpcsharp_init = PInvokeMethods.grpcsharp_init; |
| 268 | this.grpcsharp_shutdown = PInvokeMethods.grpcsharp_shutdown; |
| 269 | this.grpcsharp_version_string = PInvokeMethods.grpcsharp_version_string; |
| 270 | |
| 271 | this.grpcsharp_batch_context_create = PInvokeMethods.grpcsharp_batch_context_create; |
| 272 | this.grpcsharp_batch_context_recv_initial_metadata = PInvokeMethods.grpcsharp_batch_context_recv_initial_metadata; |
| 273 | this.grpcsharp_batch_context_recv_message_length = PInvokeMethods.grpcsharp_batch_context_recv_message_length; |
| 274 | this.grpcsharp_batch_context_recv_message_to_buffer = PInvokeMethods.grpcsharp_batch_context_recv_message_to_buffer; |
| 275 | this.grpcsharp_batch_context_recv_status_on_client_status = PInvokeMethods.grpcsharp_batch_context_recv_status_on_client_status; |
| 276 | this.grpcsharp_batch_context_recv_status_on_client_details = PInvokeMethods.grpcsharp_batch_context_recv_status_on_client_details; |
| 277 | this.grpcsharp_batch_context_recv_status_on_client_trailing_metadata = PInvokeMethods.grpcsharp_batch_context_recv_status_on_client_trailing_metadata; |
| 278 | this.grpcsharp_batch_context_server_rpc_new_call = PInvokeMethods.grpcsharp_batch_context_server_rpc_new_call; |
| 279 | this.grpcsharp_batch_context_server_rpc_new_method = PInvokeMethods.grpcsharp_batch_context_server_rpc_new_method; |
| 280 | this.grpcsharp_batch_context_server_rpc_new_host = PInvokeMethods.grpcsharp_batch_context_server_rpc_new_host; |
| 281 | this.grpcsharp_batch_context_server_rpc_new_deadline = PInvokeMethods.grpcsharp_batch_context_server_rpc_new_deadline; |
| 282 | this.grpcsharp_batch_context_server_rpc_new_request_metadata = PInvokeMethods.grpcsharp_batch_context_server_rpc_new_request_metadata; |
| 283 | this.grpcsharp_batch_context_recv_close_on_server_cancelled = PInvokeMethods.grpcsharp_batch_context_recv_close_on_server_cancelled; |
| 284 | this.grpcsharp_batch_context_destroy = PInvokeMethods.grpcsharp_batch_context_destroy; |
| 285 | |
| 286 | this.grpcsharp_composite_call_credentials_create = PInvokeMethods.grpcsharp_composite_call_credentials_create; |
| 287 | this.grpcsharp_call_credentials_release = PInvokeMethods.grpcsharp_call_credentials_release; |
| 288 | |
| 289 | this.grpcsharp_call_cancel = PInvokeMethods.grpcsharp_call_cancel; |
| 290 | this.grpcsharp_call_cancel_with_status = PInvokeMethods.grpcsharp_call_cancel_with_status; |
| 291 | this.grpcsharp_call_start_unary = PInvokeMethods.grpcsharp_call_start_unary; |
| 292 | this.grpcsharp_call_start_client_streaming = PInvokeMethods.grpcsharp_call_start_client_streaming; |
| 293 | this.grpcsharp_call_start_server_streaming = PInvokeMethods.grpcsharp_call_start_server_streaming; |
| 294 | this.grpcsharp_call_start_duplex_streaming = PInvokeMethods.grpcsharp_call_start_duplex_streaming; |
| 295 | this.grpcsharp_call_send_message = PInvokeMethods.grpcsharp_call_send_message; |
| 296 | this.grpcsharp_call_send_close_from_client = PInvokeMethods.grpcsharp_call_send_close_from_client; |
| 297 | this.grpcsharp_call_send_status_from_server = PInvokeMethods.grpcsharp_call_send_status_from_server; |
| 298 | this.grpcsharp_call_recv_message = PInvokeMethods.grpcsharp_call_recv_message; |
| 299 | this.grpcsharp_call_recv_initial_metadata = PInvokeMethods.grpcsharp_call_recv_initial_metadata; |
| 300 | this.grpcsharp_call_start_serverside = PInvokeMethods.grpcsharp_call_start_serverside; |
| 301 | this.grpcsharp_call_send_initial_metadata = PInvokeMethods.grpcsharp_call_send_initial_metadata; |
| 302 | this.grpcsharp_call_set_credentials = PInvokeMethods.grpcsharp_call_set_credentials; |
| 303 | this.grpcsharp_call_get_peer = PInvokeMethods.grpcsharp_call_get_peer; |
| 304 | this.grpcsharp_call_destroy = PInvokeMethods.grpcsharp_call_destroy; |
| 305 | |
| 306 | this.grpcsharp_channel_args_create = PInvokeMethods.grpcsharp_channel_args_create; |
| 307 | this.grpcsharp_channel_args_set_string = PInvokeMethods.grpcsharp_channel_args_set_string; |
| 308 | this.grpcsharp_channel_args_set_integer = PInvokeMethods.grpcsharp_channel_args_set_integer; |
| 309 | this.grpcsharp_channel_args_destroy = PInvokeMethods.grpcsharp_channel_args_destroy; |
| 310 | |
Jan Tattermusch | 660c15b | 2016-02-02 06:39:10 -0800 | [diff] [blame] | 311 | this.grpcsharp_override_default_ssl_roots = PInvokeMethods.grpcsharp_override_default_ssl_roots; |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 312 | this.grpcsharp_ssl_credentials_create = PInvokeMethods.grpcsharp_ssl_credentials_create; |
| 313 | this.grpcsharp_composite_channel_credentials_create = PInvokeMethods.grpcsharp_composite_channel_credentials_create; |
| 314 | this.grpcsharp_channel_credentials_release = PInvokeMethods.grpcsharp_channel_credentials_release; |
| 315 | |
| 316 | this.grpcsharp_insecure_channel_create = PInvokeMethods.grpcsharp_insecure_channel_create; |
| 317 | this.grpcsharp_secure_channel_create = PInvokeMethods.grpcsharp_secure_channel_create; |
| 318 | this.grpcsharp_channel_create_call = PInvokeMethods.grpcsharp_channel_create_call; |
| 319 | this.grpcsharp_channel_check_connectivity_state = PInvokeMethods.grpcsharp_channel_check_connectivity_state; |
| 320 | this.grpcsharp_channel_watch_connectivity_state = PInvokeMethods.grpcsharp_channel_watch_connectivity_state; |
| 321 | this.grpcsharp_channel_get_target = PInvokeMethods.grpcsharp_channel_get_target; |
| 322 | this.grpcsharp_channel_destroy = PInvokeMethods.grpcsharp_channel_destroy; |
| 323 | |
| 324 | this.grpcsharp_sizeof_grpc_event = PInvokeMethods.grpcsharp_sizeof_grpc_event; |
| 325 | |
| 326 | this.grpcsharp_completion_queue_create = PInvokeMethods.grpcsharp_completion_queue_create; |
| 327 | this.grpcsharp_completion_queue_shutdown = PInvokeMethods.grpcsharp_completion_queue_shutdown; |
| 328 | this.grpcsharp_completion_queue_next = PInvokeMethods.grpcsharp_completion_queue_next; |
| 329 | this.grpcsharp_completion_queue_pluck = PInvokeMethods.grpcsharp_completion_queue_pluck; |
| 330 | this.grpcsharp_completion_queue_destroy = PInvokeMethods.grpcsharp_completion_queue_destroy; |
| 331 | |
| 332 | this.gprsharp_free = PInvokeMethods.gprsharp_free; |
| 333 | |
| 334 | this.grpcsharp_metadata_array_create = PInvokeMethods.grpcsharp_metadata_array_create; |
| 335 | this.grpcsharp_metadata_array_add = PInvokeMethods.grpcsharp_metadata_array_add; |
| 336 | this.grpcsharp_metadata_array_count = PInvokeMethods.grpcsharp_metadata_array_count; |
| 337 | this.grpcsharp_metadata_array_get_key = PInvokeMethods.grpcsharp_metadata_array_get_key; |
| 338 | this.grpcsharp_metadata_array_get_value = PInvokeMethods.grpcsharp_metadata_array_get_value; |
| 339 | this.grpcsharp_metadata_array_get_value_length = PInvokeMethods.grpcsharp_metadata_array_get_value_length; |
| 340 | this.grpcsharp_metadata_array_destroy_full = PInvokeMethods.grpcsharp_metadata_array_destroy_full; |
| 341 | |
| 342 | this.grpcsharp_redirect_log = PInvokeMethods.grpcsharp_redirect_log; |
| 343 | |
| 344 | this.grpcsharp_metadata_credentials_create_from_plugin = PInvokeMethods.grpcsharp_metadata_credentials_create_from_plugin; |
| 345 | this.grpcsharp_metadata_credentials_notify_from_plugin = PInvokeMethods.grpcsharp_metadata_credentials_notify_from_plugin; |
| 346 | |
| 347 | this.grpcsharp_ssl_server_credentials_create = PInvokeMethods.grpcsharp_ssl_server_credentials_create; |
| 348 | this.grpcsharp_server_credentials_release = PInvokeMethods.grpcsharp_server_credentials_release; |
| 349 | |
| 350 | this.grpcsharp_server_create = PInvokeMethods.grpcsharp_server_create; |
| 351 | this.grpcsharp_server_add_insecure_http2_port = PInvokeMethods.grpcsharp_server_add_insecure_http2_port; |
| 352 | this.grpcsharp_server_add_secure_http2_port = PInvokeMethods.grpcsharp_server_add_secure_http2_port; |
| 353 | this.grpcsharp_server_start = PInvokeMethods.grpcsharp_server_start; |
| 354 | this.grpcsharp_server_request_call = PInvokeMethods.grpcsharp_server_request_call; |
| 355 | this.grpcsharp_server_cancel_all_calls = PInvokeMethods.grpcsharp_server_cancel_all_calls; |
| 356 | this.grpcsharp_server_shutdown_and_notify_callback = PInvokeMethods.grpcsharp_server_shutdown_and_notify_callback; |
| 357 | this.grpcsharp_server_destroy = PInvokeMethods.grpcsharp_server_destroy; |
| 358 | |
| 359 | this.gprsharp_now = PInvokeMethods.gprsharp_now; |
| 360 | this.gprsharp_inf_future = PInvokeMethods.gprsharp_inf_future; |
| 361 | this.gprsharp_inf_past = PInvokeMethods.gprsharp_inf_past; |
| 362 | this.gprsharp_convert_clock_type = PInvokeMethods.gprsharp_convert_clock_type; |
| 363 | this.gprsharp_sizeof_timespec = PInvokeMethods.gprsharp_sizeof_timespec; |
| 364 | |
| 365 | this.grpcsharp_test_callback = PInvokeMethods.grpcsharp_test_callback; |
| 366 | this.grpcsharp_test_nop = PInvokeMethods.grpcsharp_test_nop; |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | /// <summary> |
| 371 | /// Gets singleton instance of this class. |
| 372 | /// </summary> |
| 373 | public static NativeMethods Get() |
| 374 | { |
| 375 | return NativeExtension.Get().NativeMethods; |
| 376 | } |
| 377 | |
| 378 | static T GetMethodDelegate<T>(UnmanagedLibrary library) |
| 379 | where T : class |
| 380 | { |
| 381 | var methodName = RemoveStringSuffix(typeof(T).Name, "_delegate"); |
| 382 | return library.GetNativeMethodDelegate<T>(methodName); |
| 383 | } |
| 384 | |
| 385 | static string RemoveStringSuffix(string str, string toRemove) |
| 386 | { |
| 387 | if (!str.EndsWith(toRemove)) |
| 388 | { |
| 389 | return str; |
| 390 | } |
| 391 | return str.Substring(0, str.Length - toRemove.Length); |
| 392 | } |
| 393 | |
| 394 | /// <summary> |
| 395 | /// Delegate types for all published native methods. Declared under inner class to prevent scope pollution. |
| 396 | /// </summary> |
| 397 | public class Delegates |
| 398 | { |
| 399 | public delegate void grpcsharp_init_delegate(); |
| 400 | public delegate void grpcsharp_shutdown_delegate(); |
| 401 | public delegate IntPtr grpcsharp_version_string_delegate(); // returns not-owned const char* |
| 402 | |
| 403 | public delegate BatchContextSafeHandle grpcsharp_batch_context_create_delegate(); |
| 404 | public delegate IntPtr grpcsharp_batch_context_recv_initial_metadata_delegate(BatchContextSafeHandle ctx); |
| 405 | public delegate IntPtr grpcsharp_batch_context_recv_message_length_delegate(BatchContextSafeHandle ctx); |
| 406 | public delegate void grpcsharp_batch_context_recv_message_to_buffer_delegate(BatchContextSafeHandle ctx, byte[] buffer, UIntPtr bufferLen); |
| 407 | public delegate StatusCode grpcsharp_batch_context_recv_status_on_client_status_delegate(BatchContextSafeHandle ctx); |
| 408 | public delegate IntPtr grpcsharp_batch_context_recv_status_on_client_details_delegate(BatchContextSafeHandle ctx); // returns const char* |
| 409 | public delegate IntPtr grpcsharp_batch_context_recv_status_on_client_trailing_metadata_delegate(BatchContextSafeHandle ctx); |
| 410 | public delegate CallSafeHandle grpcsharp_batch_context_server_rpc_new_call_delegate(BatchContextSafeHandle ctx); |
| 411 | public delegate IntPtr grpcsharp_batch_context_server_rpc_new_method_delegate(BatchContextSafeHandle ctx); // returns const char* |
| 412 | public delegate IntPtr grpcsharp_batch_context_server_rpc_new_host_delegate(BatchContextSafeHandle ctx); // returns const char* |
| 413 | public delegate Timespec grpcsharp_batch_context_server_rpc_new_deadline_delegate(BatchContextSafeHandle ctx); |
| 414 | public delegate IntPtr grpcsharp_batch_context_server_rpc_new_request_metadata_delegate(BatchContextSafeHandle ctx); |
| 415 | public delegate int grpcsharp_batch_context_recv_close_on_server_cancelled_delegate(BatchContextSafeHandle ctx); |
| 416 | public delegate void grpcsharp_batch_context_destroy_delegate(IntPtr ctx); |
| 417 | |
| 418 | public delegate CallCredentialsSafeHandle grpcsharp_composite_call_credentials_create_delegate(CallCredentialsSafeHandle creds1, CallCredentialsSafeHandle creds2); |
| 419 | public delegate void grpcsharp_call_credentials_release_delegate(IntPtr credentials); |
| 420 | |
| 421 | public delegate GRPCCallError grpcsharp_call_cancel_delegate(CallSafeHandle call); |
| 422 | public delegate GRPCCallError grpcsharp_call_cancel_with_status_delegate(CallSafeHandle call, StatusCode status, string description); |
| 423 | public delegate GRPCCallError grpcsharp_call_start_unary_delegate(CallSafeHandle call, |
Jan Tattermusch | 305ffd4 | 2016-05-04 10:26:24 -0700 | [diff] [blame] | 424 | BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 425 | public delegate GRPCCallError grpcsharp_call_start_client_streaming_delegate(CallSafeHandle call, |
| 426 | BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray); |
| 427 | public delegate GRPCCallError grpcsharp_call_start_server_streaming_delegate(CallSafeHandle call, |
Jan Tattermusch | 305ffd4 | 2016-05-04 10:26:24 -0700 | [diff] [blame] | 428 | BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 429 | MetadataArraySafeHandle metadataArray, WriteFlags writeFlags); |
| 430 | public delegate GRPCCallError grpcsharp_call_start_duplex_streaming_delegate(CallSafeHandle call, |
| 431 | BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray); |
| 432 | public delegate GRPCCallError grpcsharp_call_send_message_delegate(CallSafeHandle call, |
Jan Tattermusch | 305ffd4 | 2016-05-04 10:26:24 -0700 | [diff] [blame] | 433 | BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, bool sendEmptyInitialMetadata); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 434 | public delegate GRPCCallError grpcsharp_call_send_close_from_client_delegate(CallSafeHandle call, |
| 435 | BatchContextSafeHandle ctx); |
| 436 | public delegate GRPCCallError grpcsharp_call_send_status_from_server_delegate(CallSafeHandle call, |
Jan Tattermusch | 305ffd4 | 2016-05-04 10:26:24 -0700 | [diff] [blame] | 437 | BatchContextSafeHandle ctx, StatusCode statusCode, string statusMessage, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, |
| 438 | byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 439 | public delegate GRPCCallError grpcsharp_call_recv_message_delegate(CallSafeHandle call, |
| 440 | BatchContextSafeHandle ctx); |
| 441 | public delegate GRPCCallError grpcsharp_call_recv_initial_metadata_delegate(CallSafeHandle call, |
| 442 | BatchContextSafeHandle ctx); |
| 443 | public delegate GRPCCallError grpcsharp_call_start_serverside_delegate(CallSafeHandle call, |
| 444 | BatchContextSafeHandle ctx); |
| 445 | public delegate GRPCCallError grpcsharp_call_send_initial_metadata_delegate(CallSafeHandle call, |
| 446 | BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray); |
| 447 | public delegate GRPCCallError grpcsharp_call_set_credentials_delegate(CallSafeHandle call, CallCredentialsSafeHandle credentials); |
| 448 | public delegate CStringSafeHandle grpcsharp_call_get_peer_delegate(CallSafeHandle call); |
| 449 | public delegate void grpcsharp_call_destroy_delegate(IntPtr call); |
| 450 | |
| 451 | public delegate ChannelArgsSafeHandle grpcsharp_channel_args_create_delegate(UIntPtr numArgs); |
| 452 | public delegate void grpcsharp_channel_args_set_string_delegate(ChannelArgsSafeHandle args, UIntPtr index, string key, string value); |
| 453 | public delegate void grpcsharp_channel_args_set_integer_delegate(ChannelArgsSafeHandle args, UIntPtr index, string key, int value); |
| 454 | public delegate void grpcsharp_channel_args_destroy_delegate(IntPtr args); |
| 455 | |
Jan Tattermusch | 660c15b | 2016-02-02 06:39:10 -0800 | [diff] [blame] | 456 | public delegate void grpcsharp_override_default_ssl_roots(string pemRootCerts); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 457 | public delegate ChannelCredentialsSafeHandle grpcsharp_ssl_credentials_create_delegate(string pemRootCerts, string keyCertPairCertChain, string keyCertPairPrivateKey); |
| 458 | public delegate ChannelCredentialsSafeHandle grpcsharp_composite_channel_credentials_create_delegate(ChannelCredentialsSafeHandle channelCreds, CallCredentialsSafeHandle callCreds); |
| 459 | public delegate void grpcsharp_channel_credentials_release_delegate(IntPtr credentials); |
| 460 | |
| 461 | public delegate ChannelSafeHandle grpcsharp_insecure_channel_create_delegate(string target, ChannelArgsSafeHandle channelArgs); |
| 462 | public delegate ChannelSafeHandle grpcsharp_secure_channel_create_delegate(ChannelCredentialsSafeHandle credentials, string target, ChannelArgsSafeHandle channelArgs); |
| 463 | public delegate CallSafeHandle grpcsharp_channel_create_call_delegate(ChannelSafeHandle channel, CallSafeHandle parentCall, ContextPropagationFlags propagationMask, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline); |
| 464 | public delegate ChannelState grpcsharp_channel_check_connectivity_state_delegate(ChannelSafeHandle channel, int tryToConnect); |
| 465 | public delegate void grpcsharp_channel_watch_connectivity_state_delegate(ChannelSafeHandle channel, ChannelState lastObservedState, |
| 466 | Timespec deadline, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx); |
| 467 | public delegate CStringSafeHandle grpcsharp_channel_get_target_delegate(ChannelSafeHandle call); |
| 468 | public delegate void grpcsharp_channel_destroy_delegate(IntPtr channel); |
| 469 | |
| 470 | public delegate int grpcsharp_sizeof_grpc_event_delegate(); |
| 471 | |
| 472 | public delegate CompletionQueueSafeHandle grpcsharp_completion_queue_create_delegate(); |
| 473 | public delegate void grpcsharp_completion_queue_shutdown_delegate(CompletionQueueSafeHandle cq); |
| 474 | public delegate CompletionQueueEvent grpcsharp_completion_queue_next_delegate(CompletionQueueSafeHandle cq); |
| 475 | public delegate CompletionQueueEvent grpcsharp_completion_queue_pluck_delegate(CompletionQueueSafeHandle cq, IntPtr tag); |
| 476 | public delegate void grpcsharp_completion_queue_destroy_delegate(IntPtr cq); |
| 477 | |
| 478 | public delegate void gprsharp_free_delegate(IntPtr ptr); |
| 479 | |
| 480 | public delegate MetadataArraySafeHandle grpcsharp_metadata_array_create_delegate(UIntPtr capacity); |
| 481 | public delegate void grpcsharp_metadata_array_add_delegate(MetadataArraySafeHandle array, string key, byte[] value, UIntPtr valueLength); |
| 482 | public delegate UIntPtr grpcsharp_metadata_array_count_delegate(IntPtr metadataArray); |
| 483 | public delegate IntPtr grpcsharp_metadata_array_get_key_delegate(IntPtr metadataArray, UIntPtr index); |
| 484 | public delegate IntPtr grpcsharp_metadata_array_get_value_delegate(IntPtr metadataArray, UIntPtr index); |
| 485 | public delegate UIntPtr grpcsharp_metadata_array_get_value_length_delegate(IntPtr metadataArray, UIntPtr index); |
| 486 | public delegate void grpcsharp_metadata_array_destroy_full_delegate(IntPtr array); |
| 487 | |
| 488 | public delegate void grpcsharp_redirect_log_delegate(GprLogDelegate callback); |
| 489 | |
| 490 | public delegate CallCredentialsSafeHandle grpcsharp_metadata_credentials_create_from_plugin_delegate(NativeMetadataInterceptor interceptor); |
| 491 | public delegate void grpcsharp_metadata_credentials_notify_from_plugin_delegate(IntPtr callbackPtr, IntPtr userData, MetadataArraySafeHandle metadataArray, StatusCode statusCode, string errorDetails); |
| 492 | |
| 493 | public delegate ServerCredentialsSafeHandle grpcsharp_ssl_server_credentials_create_delegate(string pemRootCerts, string[] keyCertPairCertChainArray, string[] keyCertPairPrivateKeyArray, UIntPtr numKeyCertPairs, bool forceClientAuth); |
| 494 | public delegate void grpcsharp_server_credentials_release_delegate(IntPtr credentials); |
| 495 | |
| 496 | public delegate ServerSafeHandle grpcsharp_server_create_delegate(CompletionQueueSafeHandle cq, ChannelArgsSafeHandle args); |
| 497 | public delegate int grpcsharp_server_add_insecure_http2_port_delegate(ServerSafeHandle server, string addr); |
| 498 | public delegate int grpcsharp_server_add_secure_http2_port_delegate(ServerSafeHandle server, string addr, ServerCredentialsSafeHandle creds); |
| 499 | public delegate void grpcsharp_server_start_delegate(ServerSafeHandle server); |
| 500 | public delegate GRPCCallError grpcsharp_server_request_call_delegate(ServerSafeHandle server, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx); |
| 501 | public delegate void grpcsharp_server_cancel_all_calls_delegate(ServerSafeHandle server); |
| 502 | public delegate void grpcsharp_server_shutdown_and_notify_callback_delegate(ServerSafeHandle server, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx); |
| 503 | public delegate void grpcsharp_server_destroy_delegate(IntPtr server); |
| 504 | |
| 505 | public delegate Timespec gprsharp_now_delegate(GPRClockType clockType); |
| 506 | public delegate Timespec gprsharp_inf_future_delegate(GPRClockType clockType); |
| 507 | public delegate Timespec gprsharp_inf_past_delegate(GPRClockType clockType); |
| 508 | |
| 509 | public delegate Timespec gprsharp_convert_clock_type_delegate(Timespec t, GPRClockType targetClock); |
| 510 | public delegate int gprsharp_sizeof_timespec_delegate(); |
| 511 | |
| 512 | public delegate GRPCCallError grpcsharp_test_callback_delegate([MarshalAs(UnmanagedType.FunctionPtr)] OpCompletionDelegate callback); |
| 513 | public delegate IntPtr grpcsharp_test_nop_delegate(IntPtr ptr); |
| 514 | } |
| 515 | |
| 516 | /// <summary> |
| 517 | /// Default PInvoke bindings for native methods that are used on Windows. |
| 518 | /// Alternatively, they can also be used as a fallback on Mono |
| 519 | /// (if libgrpc_csharp_ext is installed on your system, or is made accessible through e.g. LD_LIBRARY_PATH environment variable |
| 520 | /// or using Mono's dllMap feature). |
| 521 | /// </summary> |
| 522 | private class PInvokeMethods |
| 523 | { |
| 524 | // Environment |
| 525 | |
| 526 | [DllImport("grpc_csharp_ext.dll")] |
| 527 | public static extern void grpcsharp_init(); |
| 528 | |
| 529 | [DllImport("grpc_csharp_ext.dll")] |
| 530 | public static extern void grpcsharp_shutdown(); |
| 531 | |
| 532 | [DllImport("grpc_csharp_ext.dll")] |
| 533 | public static extern IntPtr grpcsharp_version_string(); // returns not-owned const char* |
| 534 | |
| 535 | // BatchContextSafeHandle |
| 536 | |
| 537 | [DllImport("grpc_csharp_ext.dll")] |
| 538 | public static extern BatchContextSafeHandle grpcsharp_batch_context_create(); |
| 539 | |
| 540 | [DllImport("grpc_csharp_ext.dll")] |
| 541 | public static extern IntPtr grpcsharp_batch_context_recv_initial_metadata(BatchContextSafeHandle ctx); |
| 542 | |
| 543 | [DllImport("grpc_csharp_ext.dll")] |
| 544 | public static extern IntPtr grpcsharp_batch_context_recv_message_length(BatchContextSafeHandle ctx); |
| 545 | |
| 546 | [DllImport("grpc_csharp_ext.dll")] |
| 547 | public static extern void grpcsharp_batch_context_recv_message_to_buffer(BatchContextSafeHandle ctx, byte[] buffer, UIntPtr bufferLen); |
| 548 | |
| 549 | [DllImport("grpc_csharp_ext.dll")] |
| 550 | public static extern StatusCode grpcsharp_batch_context_recv_status_on_client_status(BatchContextSafeHandle ctx); |
| 551 | |
| 552 | [DllImport("grpc_csharp_ext.dll")] |
| 553 | public static extern IntPtr grpcsharp_batch_context_recv_status_on_client_details(BatchContextSafeHandle ctx); // returns const char* |
| 554 | |
| 555 | [DllImport("grpc_csharp_ext.dll")] |
| 556 | public static extern IntPtr grpcsharp_batch_context_recv_status_on_client_trailing_metadata(BatchContextSafeHandle ctx); |
| 557 | |
| 558 | [DllImport("grpc_csharp_ext.dll")] |
| 559 | public static extern CallSafeHandle grpcsharp_batch_context_server_rpc_new_call(BatchContextSafeHandle ctx); |
| 560 | |
| 561 | [DllImport("grpc_csharp_ext.dll")] |
| 562 | public static extern IntPtr grpcsharp_batch_context_server_rpc_new_method(BatchContextSafeHandle ctx); // returns const char* |
| 563 | |
| 564 | [DllImport("grpc_csharp_ext.dll")] |
| 565 | public static extern IntPtr grpcsharp_batch_context_server_rpc_new_host(BatchContextSafeHandle ctx); // returns const char* |
| 566 | |
| 567 | [DllImport("grpc_csharp_ext.dll")] |
| 568 | public static extern Timespec grpcsharp_batch_context_server_rpc_new_deadline(BatchContextSafeHandle ctx); |
| 569 | |
| 570 | [DllImport("grpc_csharp_ext.dll")] |
| 571 | public static extern IntPtr grpcsharp_batch_context_server_rpc_new_request_metadata(BatchContextSafeHandle ctx); |
| 572 | |
| 573 | [DllImport("grpc_csharp_ext.dll")] |
| 574 | public static extern int grpcsharp_batch_context_recv_close_on_server_cancelled(BatchContextSafeHandle ctx); |
| 575 | |
| 576 | [DllImport("grpc_csharp_ext.dll")] |
| 577 | public static extern void grpcsharp_batch_context_destroy(IntPtr ctx); |
| 578 | |
| 579 | // CallCredentialsSafeHandle |
| 580 | |
| 581 | [DllImport("grpc_csharp_ext.dll")] |
| 582 | public static extern CallCredentialsSafeHandle grpcsharp_composite_call_credentials_create(CallCredentialsSafeHandle creds1, CallCredentialsSafeHandle creds2); |
| 583 | |
| 584 | [DllImport("grpc_csharp_ext.dll")] |
| 585 | public static extern void grpcsharp_call_credentials_release(IntPtr credentials); |
| 586 | |
| 587 | // CallSafeHandle |
| 588 | |
| 589 | [DllImport("grpc_csharp_ext.dll")] |
| 590 | public static extern GRPCCallError grpcsharp_call_cancel(CallSafeHandle call); |
| 591 | |
| 592 | [DllImport("grpc_csharp_ext.dll")] |
| 593 | public static extern GRPCCallError grpcsharp_call_cancel_with_status(CallSafeHandle call, StatusCode status, string description); |
| 594 | |
| 595 | [DllImport("grpc_csharp_ext.dll")] |
| 596 | public static extern GRPCCallError grpcsharp_call_start_unary(CallSafeHandle call, |
Jan Tattermusch | 305ffd4 | 2016-05-04 10:26:24 -0700 | [diff] [blame] | 597 | BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 598 | |
| 599 | [DllImport("grpc_csharp_ext.dll")] |
| 600 | public static extern GRPCCallError grpcsharp_call_start_client_streaming(CallSafeHandle call, |
| 601 | BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray); |
| 602 | |
| 603 | [DllImport("grpc_csharp_ext.dll")] |
| 604 | public static extern GRPCCallError grpcsharp_call_start_server_streaming(CallSafeHandle call, |
Jan Tattermusch | 305ffd4 | 2016-05-04 10:26:24 -0700 | [diff] [blame] | 605 | BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 606 | MetadataArraySafeHandle metadataArray, WriteFlags writeFlags); |
| 607 | |
| 608 | [DllImport("grpc_csharp_ext.dll")] |
| 609 | public static extern GRPCCallError grpcsharp_call_start_duplex_streaming(CallSafeHandle call, |
| 610 | BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray); |
| 611 | |
| 612 | [DllImport("grpc_csharp_ext.dll")] |
| 613 | public static extern GRPCCallError grpcsharp_call_send_message(CallSafeHandle call, |
Jan Tattermusch | 305ffd4 | 2016-05-04 10:26:24 -0700 | [diff] [blame] | 614 | BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, bool sendEmptyInitialMetadata); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 615 | |
| 616 | [DllImport("grpc_csharp_ext.dll")] |
| 617 | public static extern GRPCCallError grpcsharp_call_send_close_from_client(CallSafeHandle call, |
| 618 | BatchContextSafeHandle ctx); |
| 619 | |
| 620 | [DllImport("grpc_csharp_ext.dll")] |
| 621 | public static extern GRPCCallError grpcsharp_call_send_status_from_server(CallSafeHandle call, |
Jan Tattermusch | 305ffd4 | 2016-05-04 10:26:24 -0700 | [diff] [blame] | 622 | BatchContextSafeHandle ctx, StatusCode statusCode, string statusMessage, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, |
| 623 | byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 624 | |
| 625 | [DllImport("grpc_csharp_ext.dll")] |
| 626 | public static extern GRPCCallError grpcsharp_call_recv_message(CallSafeHandle call, |
| 627 | BatchContextSafeHandle ctx); |
| 628 | |
| 629 | [DllImport("grpc_csharp_ext.dll")] |
| 630 | public static extern GRPCCallError grpcsharp_call_recv_initial_metadata(CallSafeHandle call, |
| 631 | BatchContextSafeHandle ctx); |
| 632 | |
| 633 | [DllImport("grpc_csharp_ext.dll")] |
| 634 | public static extern GRPCCallError grpcsharp_call_start_serverside(CallSafeHandle call, |
| 635 | BatchContextSafeHandle ctx); |
| 636 | |
| 637 | [DllImport("grpc_csharp_ext.dll")] |
| 638 | public static extern GRPCCallError grpcsharp_call_send_initial_metadata(CallSafeHandle call, |
| 639 | BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray); |
| 640 | |
| 641 | [DllImport("grpc_csharp_ext.dll")] |
| 642 | public static extern GRPCCallError grpcsharp_call_set_credentials(CallSafeHandle call, CallCredentialsSafeHandle credentials); |
| 643 | |
| 644 | [DllImport("grpc_csharp_ext.dll")] |
| 645 | public static extern CStringSafeHandle grpcsharp_call_get_peer(CallSafeHandle call); |
| 646 | |
| 647 | [DllImport("grpc_csharp_ext.dll")] |
| 648 | public static extern void grpcsharp_call_destroy(IntPtr call); |
| 649 | |
| 650 | // ChannelArgsSafeHandle |
| 651 | |
| 652 | [DllImport("grpc_csharp_ext.dll")] |
| 653 | public static extern ChannelArgsSafeHandle grpcsharp_channel_args_create(UIntPtr numArgs); |
| 654 | |
| 655 | [DllImport("grpc_csharp_ext.dll", CharSet = CharSet.Ansi)] |
| 656 | public static extern void grpcsharp_channel_args_set_string(ChannelArgsSafeHandle args, UIntPtr index, string key, string value); |
| 657 | |
| 658 | [DllImport("grpc_csharp_ext.dll", CharSet = CharSet.Ansi)] |
| 659 | public static extern void grpcsharp_channel_args_set_integer(ChannelArgsSafeHandle args, UIntPtr index, string key, int value); |
| 660 | |
| 661 | [DllImport("grpc_csharp_ext.dll")] |
| 662 | public static extern void grpcsharp_channel_args_destroy(IntPtr args); |
| 663 | |
| 664 | // ChannelCredentialsSafeHandle |
| 665 | |
| 666 | [DllImport("grpc_csharp_ext.dll", CharSet = CharSet.Ansi)] |
Jan Tattermusch | 660c15b | 2016-02-02 06:39:10 -0800 | [diff] [blame] | 667 | public static extern void grpcsharp_override_default_ssl_roots(string pemRootCerts); |
| 668 | |
| 669 | [DllImport("grpc_csharp_ext.dll", CharSet = CharSet.Ansi)] |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 670 | public static extern ChannelCredentialsSafeHandle grpcsharp_ssl_credentials_create(string pemRootCerts, string keyCertPairCertChain, string keyCertPairPrivateKey); |
| 671 | |
| 672 | [DllImport("grpc_csharp_ext.dll")] |
| 673 | public static extern ChannelCredentialsSafeHandle grpcsharp_composite_channel_credentials_create(ChannelCredentialsSafeHandle channelCreds, CallCredentialsSafeHandle callCreds); |
| 674 | |
| 675 | [DllImport("grpc_csharp_ext.dll")] |
| 676 | public static extern void grpcsharp_channel_credentials_release(IntPtr credentials); |
| 677 | |
| 678 | // ChannelSafeHandle |
| 679 | |
| 680 | [DllImport("grpc_csharp_ext.dll")] |
| 681 | public static extern ChannelSafeHandle grpcsharp_insecure_channel_create(string target, ChannelArgsSafeHandle channelArgs); |
| 682 | |
| 683 | [DllImport("grpc_csharp_ext.dll")] |
| 684 | public static extern ChannelSafeHandle grpcsharp_secure_channel_create(ChannelCredentialsSafeHandle credentials, string target, ChannelArgsSafeHandle channelArgs); |
| 685 | |
| 686 | [DllImport("grpc_csharp_ext.dll")] |
| 687 | public static extern CallSafeHandle grpcsharp_channel_create_call(ChannelSafeHandle channel, CallSafeHandle parentCall, ContextPropagationFlags propagationMask, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline); |
| 688 | |
| 689 | [DllImport("grpc_csharp_ext.dll")] |
| 690 | public static extern ChannelState grpcsharp_channel_check_connectivity_state(ChannelSafeHandle channel, int tryToConnect); |
| 691 | |
| 692 | [DllImport("grpc_csharp_ext.dll")] |
| 693 | public static extern void grpcsharp_channel_watch_connectivity_state(ChannelSafeHandle channel, ChannelState lastObservedState, |
| 694 | Timespec deadline, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx); |
| 695 | |
| 696 | [DllImport("grpc_csharp_ext.dll")] |
| 697 | public static extern CStringSafeHandle grpcsharp_channel_get_target(ChannelSafeHandle call); |
| 698 | |
| 699 | [DllImport("grpc_csharp_ext.dll")] |
| 700 | public static extern void grpcsharp_channel_destroy(IntPtr channel); |
| 701 | |
| 702 | // CompletionQueueEvent |
| 703 | |
| 704 | [DllImport("grpc_csharp_ext.dll")] |
| 705 | public static extern int grpcsharp_sizeof_grpc_event(); |
| 706 | |
| 707 | // CompletionQueueSafeHandle |
| 708 | |
| 709 | [DllImport("grpc_csharp_ext.dll")] |
| 710 | public static extern CompletionQueueSafeHandle grpcsharp_completion_queue_create(); |
| 711 | |
| 712 | [DllImport("grpc_csharp_ext.dll")] |
| 713 | public static extern void grpcsharp_completion_queue_shutdown(CompletionQueueSafeHandle cq); |
| 714 | |
| 715 | [DllImport("grpc_csharp_ext.dll")] |
| 716 | public static extern CompletionQueueEvent grpcsharp_completion_queue_next(CompletionQueueSafeHandle cq); |
| 717 | |
| 718 | [DllImport("grpc_csharp_ext.dll")] |
| 719 | public static extern CompletionQueueEvent grpcsharp_completion_queue_pluck(CompletionQueueSafeHandle cq, IntPtr tag); |
| 720 | |
| 721 | [DllImport("grpc_csharp_ext.dll")] |
| 722 | public static extern void grpcsharp_completion_queue_destroy(IntPtr cq); |
| 723 | |
| 724 | // CStringSafeHandle |
| 725 | |
| 726 | [DllImport("grpc_csharp_ext.dll")] |
| 727 | public static extern void gprsharp_free(IntPtr ptr); |
| 728 | |
| 729 | // MetadataArraySafeHandle |
| 730 | |
| 731 | [DllImport("grpc_csharp_ext.dll")] |
| 732 | public static extern MetadataArraySafeHandle grpcsharp_metadata_array_create(UIntPtr capacity); |
| 733 | |
| 734 | [DllImport("grpc_csharp_ext.dll", CharSet = CharSet.Ansi)] |
| 735 | public static extern void grpcsharp_metadata_array_add(MetadataArraySafeHandle array, string key, byte[] value, UIntPtr valueLength); |
| 736 | |
| 737 | [DllImport("grpc_csharp_ext.dll")] |
| 738 | public static extern UIntPtr grpcsharp_metadata_array_count(IntPtr metadataArray); |
| 739 | |
| 740 | [DllImport("grpc_csharp_ext.dll")] |
| 741 | public static extern IntPtr grpcsharp_metadata_array_get_key(IntPtr metadataArray, UIntPtr index); |
| 742 | |
| 743 | [DllImport("grpc_csharp_ext.dll")] |
| 744 | public static extern IntPtr grpcsharp_metadata_array_get_value(IntPtr metadataArray, UIntPtr index); |
| 745 | |
| 746 | [DllImport("grpc_csharp_ext.dll")] |
| 747 | public static extern UIntPtr grpcsharp_metadata_array_get_value_length(IntPtr metadataArray, UIntPtr index); |
| 748 | |
| 749 | [DllImport("grpc_csharp_ext.dll")] |
| 750 | public static extern void grpcsharp_metadata_array_destroy_full(IntPtr array); |
| 751 | |
| 752 | // NativeLogRedirector |
| 753 | |
| 754 | [DllImport("grpc_csharp_ext.dll")] |
| 755 | public static extern void grpcsharp_redirect_log(GprLogDelegate callback); |
| 756 | |
| 757 | // NativeMetadataCredentialsPlugin |
| 758 | |
| 759 | [DllImport("grpc_csharp_ext.dll")] |
| 760 | public static extern CallCredentialsSafeHandle grpcsharp_metadata_credentials_create_from_plugin(NativeMetadataInterceptor interceptor); |
| 761 | |
| 762 | [DllImport("grpc_csharp_ext.dll", CharSet = CharSet.Ansi)] |
| 763 | public static extern void grpcsharp_metadata_credentials_notify_from_plugin(IntPtr callbackPtr, IntPtr userData, MetadataArraySafeHandle metadataArray, StatusCode statusCode, string errorDetails); |
| 764 | |
| 765 | // ServerCredentialsSafeHandle |
| 766 | |
| 767 | [DllImport("grpc_csharp_ext.dll", CharSet = CharSet.Ansi)] |
| 768 | public static extern ServerCredentialsSafeHandle grpcsharp_ssl_server_credentials_create(string pemRootCerts, string[] keyCertPairCertChainArray, string[] keyCertPairPrivateKeyArray, UIntPtr numKeyCertPairs, bool forceClientAuth); |
| 769 | |
| 770 | [DllImport("grpc_csharp_ext.dll")] |
| 771 | public static extern void grpcsharp_server_credentials_release(IntPtr credentials); |
| 772 | |
| 773 | // ServerSafeHandle |
| 774 | |
| 775 | [DllImport("grpc_csharp_ext.dll")] |
| 776 | public static extern ServerSafeHandle grpcsharp_server_create(CompletionQueueSafeHandle cq, ChannelArgsSafeHandle args); |
| 777 | |
| 778 | [DllImport("grpc_csharp_ext.dll")] |
| 779 | public static extern int grpcsharp_server_add_insecure_http2_port(ServerSafeHandle server, string addr); |
| 780 | |
| 781 | [DllImport("grpc_csharp_ext.dll")] |
| 782 | public static extern int grpcsharp_server_add_secure_http2_port(ServerSafeHandle server, string addr, ServerCredentialsSafeHandle creds); |
| 783 | |
| 784 | [DllImport("grpc_csharp_ext.dll")] |
| 785 | public static extern void grpcsharp_server_start(ServerSafeHandle server); |
| 786 | |
| 787 | [DllImport("grpc_csharp_ext.dll")] |
| 788 | public static extern GRPCCallError grpcsharp_server_request_call(ServerSafeHandle server, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx); |
| 789 | |
| 790 | [DllImport("grpc_csharp_ext.dll")] |
| 791 | public static extern void grpcsharp_server_cancel_all_calls(ServerSafeHandle server); |
| 792 | |
| 793 | [DllImport("grpc_csharp_ext.dll")] |
| 794 | public static extern void grpcsharp_server_shutdown_and_notify_callback(ServerSafeHandle server, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx); |
| 795 | |
| 796 | [DllImport("grpc_csharp_ext.dll")] |
| 797 | public static extern void grpcsharp_server_destroy(IntPtr server); |
| 798 | |
| 799 | // Timespec |
| 800 | |
| 801 | [DllImport("grpc_csharp_ext.dll")] |
| 802 | public static extern Timespec gprsharp_now(GPRClockType clockType); |
| 803 | |
| 804 | [DllImport("grpc_csharp_ext.dll")] |
| 805 | public static extern Timespec gprsharp_inf_future(GPRClockType clockType); |
| 806 | |
| 807 | [DllImport("grpc_csharp_ext.dll")] |
| 808 | public static extern Timespec gprsharp_inf_past(GPRClockType clockType); |
| 809 | |
| 810 | [DllImport("grpc_csharp_ext.dll")] |
| 811 | public static extern Timespec gprsharp_convert_clock_type(Timespec t, GPRClockType targetClock); |
| 812 | |
| 813 | [DllImport("grpc_csharp_ext.dll")] |
| 814 | public static extern int gprsharp_sizeof_timespec(); |
| 815 | |
| 816 | // Testing |
| 817 | |
| 818 | [DllImport("grpc_csharp_ext.dll")] |
| 819 | public static extern GRPCCallError grpcsharp_test_callback([MarshalAs(UnmanagedType.FunctionPtr)] OpCompletionDelegate callback); |
| 820 | |
| 821 | [DllImport("grpc_csharp_ext.dll")] |
| 822 | public static extern IntPtr grpcsharp_test_nop(IntPtr ptr); |
| 823 | } |
| 824 | } |
| 825 | } |