|
|
|
@ -38,7 +38,6 @@ using Grpc.Core; |
|
|
|
|
namespace Grpc.Core.Internal |
|
|
|
|
{ |
|
|
|
|
/// <summary> |
|
|
|
|
/// Not owned version of |
|
|
|
|
/// grpcsharp_batch_context |
|
|
|
|
/// </summary> |
|
|
|
|
internal class BatchContextSafeHandle : SafeHandleZeroIsInvalid |
|
|
|
@ -47,7 +46,7 @@ namespace Grpc.Core.Internal |
|
|
|
|
static extern BatchContextSafeHandle grpcsharp_batch_context_create(); |
|
|
|
|
|
|
|
|
|
[DllImport("grpc_csharp_ext.dll")] |
|
|
|
|
static extern IntPtr grpcsharp_batch_context_receive_initial_metadata(BatchContextSafeHandle ctx); |
|
|
|
|
static extern IntPtr grpcsharp_batch_context_recv_initial_metadata(BatchContextSafeHandle ctx); |
|
|
|
|
|
|
|
|
|
[DllImport("grpc_csharp_ext.dll")] |
|
|
|
|
static extern IntPtr grpcsharp_batch_context_recv_message_length(BatchContextSafeHandle ctx); |
|
|
|
@ -70,6 +69,12 @@ namespace Grpc.Core.Internal |
|
|
|
|
[DllImport("grpc_csharp_ext.dll")] |
|
|
|
|
static extern IntPtr grpcsharp_batch_context_server_rpc_new_method(BatchContextSafeHandle ctx); // returns const char* |
|
|
|
|
|
|
|
|
|
[DllImport("grpc_csharp_ext.dll")] |
|
|
|
|
static extern IntPtr grpcsharp_batch_context_server_rpc_new_host(BatchContextSafeHandle ctx); // returns const char* |
|
|
|
|
|
|
|
|
|
[DllImport("grpc_csharp_ext.dll")] |
|
|
|
|
static extern Timespec grpcsharp_batch_context_server_rpc_new_deadline(BatchContextSafeHandle ctx); |
|
|
|
|
|
|
|
|
|
[DllImport("grpc_csharp_ext.dll")] |
|
|
|
|
static extern IntPtr grpcsharp_batch_context_server_rpc_new_request_metadata(BatchContextSafeHandle ctx); |
|
|
|
|
|
|
|
|
@ -96,24 +101,26 @@ namespace Grpc.Core.Internal |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Gets data of recv_initial_metadata completion. |
|
|
|
|
public Metadata GetReceivedInitialMetadata() |
|
|
|
|
{ |
|
|
|
|
IntPtr metadataArrayPtr = grpcsharp_batch_context_receive_initial_metadata(this); |
|
|
|
|
IntPtr metadataArrayPtr = grpcsharp_batch_context_recv_initial_metadata(this); |
|
|
|
|
return MetadataArraySafeHandle.ReadMetadataFromPtrUnsafe(metadataArrayPtr); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Status GetReceivedStatus() |
|
|
|
|
|
|
|
|
|
// Gets data of recv_status_on_client completion. |
|
|
|
|
public ClientSideStatus GetReceivedStatusOnClient() |
|
|
|
|
{ |
|
|
|
|
string details = Marshal.PtrToStringAnsi(grpcsharp_batch_context_recv_status_on_client_details(this)); |
|
|
|
|
return new Status(grpcsharp_batch_context_recv_status_on_client_status(this), details); |
|
|
|
|
} |
|
|
|
|
var status = new Status(grpcsharp_batch_context_recv_status_on_client_status(this), details); |
|
|
|
|
|
|
|
|
|
public Metadata GetReceivedStatusTrailingMetadata() |
|
|
|
|
{ |
|
|
|
|
IntPtr metadataArrayPtr = grpcsharp_batch_context_recv_status_on_client_trailing_metadata(this); |
|
|
|
|
return MetadataArraySafeHandle.ReadMetadataFromPtrUnsafe(metadataArrayPtr); |
|
|
|
|
var metadata = MetadataArraySafeHandle.ReadMetadataFromPtrUnsafe(metadataArrayPtr); |
|
|
|
|
|
|
|
|
|
return new ClientSideStatus(status, metadata); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Gets data of recv_message completion. |
|
|
|
|
public byte[] GetReceivedMessage() |
|
|
|
|
{ |
|
|
|
|
IntPtr len = grpcsharp_batch_context_recv_message_length(this); |
|
|
|
@ -126,22 +133,22 @@ namespace Grpc.Core.Internal |
|
|
|
|
return data; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public CallSafeHandle GetServerRpcNewCall() |
|
|
|
|
// Gets data of server_rpc_new completion. |
|
|
|
|
public ServerRpcNew GetServerRpcNew() |
|
|
|
|
{ |
|
|
|
|
return grpcsharp_batch_context_server_rpc_new_call(this); |
|
|
|
|
} |
|
|
|
|
var call = grpcsharp_batch_context_server_rpc_new_call(this); |
|
|
|
|
|
|
|
|
|
public string GetServerRpcNewMethod() |
|
|
|
|
{ |
|
|
|
|
return Marshal.PtrToStringAnsi(grpcsharp_batch_context_server_rpc_new_method(this)); |
|
|
|
|
} |
|
|
|
|
var method = Marshal.PtrToStringAnsi(grpcsharp_batch_context_server_rpc_new_method(this)); |
|
|
|
|
var host = Marshal.PtrToStringAnsi(grpcsharp_batch_context_server_rpc_new_host(this)); |
|
|
|
|
var deadline = grpcsharp_batch_context_server_rpc_new_deadline(this); |
|
|
|
|
|
|
|
|
|
public Metadata GetServerRpcNewRequestMetadata() |
|
|
|
|
{ |
|
|
|
|
IntPtr metadataArrayPtr = grpcsharp_batch_context_server_rpc_new_request_metadata(this); |
|
|
|
|
return MetadataArraySafeHandle.ReadMetadataFromPtrUnsafe(metadataArrayPtr); |
|
|
|
|
var metadata = MetadataArraySafeHandle.ReadMetadataFromPtrUnsafe(metadataArrayPtr); |
|
|
|
|
|
|
|
|
|
return new ServerRpcNew(call, method, host, deadline, metadata); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Gets data of receive_close_on_server completion. |
|
|
|
|
public bool GetReceivedCloseOnServerCancelled() |
|
|
|
|
{ |
|
|
|
|
return grpcsharp_batch_context_recv_close_on_server_cancelled(this) != 0; |
|
|
|
@ -153,4 +160,97 @@ namespace Grpc.Core.Internal |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Status + metadata received on client side when call finishes. |
|
|
|
|
/// (when receive_status_on_client operation finishes). |
|
|
|
|
/// </summary> |
|
|
|
|
internal struct ClientSideStatus |
|
|
|
|
{ |
|
|
|
|
readonly Status status; |
|
|
|
|
readonly Metadata trailers; |
|
|
|
|
|
|
|
|
|
public ClientSideStatus(Status status, Metadata trailers) |
|
|
|
|
{ |
|
|
|
|
this.status = status; |
|
|
|
|
this.trailers = trailers; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Status Status |
|
|
|
|
{ |
|
|
|
|
get |
|
|
|
|
{ |
|
|
|
|
return this.status; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Metadata Trailers |
|
|
|
|
{ |
|
|
|
|
get |
|
|
|
|
{ |
|
|
|
|
return this.trailers; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Details of a newly received RPC. |
|
|
|
|
/// </summary> |
|
|
|
|
internal struct ServerRpcNew |
|
|
|
|
{ |
|
|
|
|
readonly CallSafeHandle call; |
|
|
|
|
readonly string method; |
|
|
|
|
readonly string host; |
|
|
|
|
readonly Timespec deadline; |
|
|
|
|
readonly Metadata requestMetadata; |
|
|
|
|
|
|
|
|
|
public ServerRpcNew(CallSafeHandle call, string method, string host, Timespec deadline, Metadata requestMetadata) |
|
|
|
|
{ |
|
|
|
|
this.call = call; |
|
|
|
|
this.method = method; |
|
|
|
|
this.host = host; |
|
|
|
|
this.deadline = deadline; |
|
|
|
|
this.requestMetadata = requestMetadata; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public CallSafeHandle Call |
|
|
|
|
{ |
|
|
|
|
get |
|
|
|
|
{ |
|
|
|
|
return this.call; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public string Method |
|
|
|
|
{ |
|
|
|
|
get |
|
|
|
|
{ |
|
|
|
|
return this.method; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public string Host |
|
|
|
|
{ |
|
|
|
|
get |
|
|
|
|
{ |
|
|
|
|
return this.host; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Timespec Deadline |
|
|
|
|
{ |
|
|
|
|
get |
|
|
|
|
{ |
|
|
|
|
return this.deadline; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Metadata RequestMetadata |
|
|
|
|
{ |
|
|
|
|
get |
|
|
|
|
{ |
|
|
|
|
return this.requestMetadata; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |