1 #region Copyright notice and license 2 // Copyright 2015 gRPC authors. 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 #endregion 17 18 using System; 19 using Grpc.Core; 20 21 namespace Grpc.Core.Internal 22 { 23 internal interface IUnaryResponseClientCallback 24 { OnUnaryResponseClient(bool success, ClientSideStatus receivedStatus, byte[] receivedMessage, Metadata responseHeaders)25 void OnUnaryResponseClient(bool success, ClientSideStatus receivedStatus, byte[] receivedMessage, Metadata responseHeaders); 26 } 27 28 // Received status for streaming response calls. 29 internal interface IReceivedStatusOnClientCallback 30 { OnReceivedStatusOnClient(bool success, ClientSideStatus receivedStatus)31 void OnReceivedStatusOnClient(bool success, ClientSideStatus receivedStatus); 32 } 33 34 internal interface IReceivedMessageCallback 35 { OnReceivedMessage(bool success, byte[] receivedMessage)36 void OnReceivedMessage(bool success, byte[] receivedMessage); 37 } 38 39 internal interface IReceivedResponseHeadersCallback 40 { OnReceivedResponseHeaders(bool success, Metadata responseHeaders)41 void OnReceivedResponseHeaders(bool success, Metadata responseHeaders); 42 } 43 44 internal interface ISendCompletionCallback 45 { OnSendCompletion(bool success)46 void OnSendCompletion(bool success); 47 } 48 49 internal interface ISendStatusFromServerCompletionCallback 50 { OnSendStatusFromServerCompletion(bool success)51 void OnSendStatusFromServerCompletion(bool success); 52 } 53 54 internal interface IReceivedCloseOnServerCallback 55 { OnReceivedCloseOnServer(bool success, bool cancelled)56 void OnReceivedCloseOnServer(bool success, bool cancelled); 57 } 58 59 /// <summary> 60 /// Abstraction of a native call object. 61 /// </summary> 62 internal interface INativeCall : IDisposable 63 { Cancel()64 void Cancel(); 65 CancelWithStatus(Status status)66 void CancelWithStatus(Status status); 67 GetPeer()68 string GetPeer(); 69 StartUnary(IUnaryResponseClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags)70 void StartUnary(IUnaryResponseClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); 71 StartUnary(BatchContextSafeHandle ctx, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags)72 void StartUnary(BatchContextSafeHandle ctx, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); 73 StartClientStreaming(IUnaryResponseClientCallback callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags)74 void StartClientStreaming(IUnaryResponseClientCallback callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags); 75 StartServerStreaming(IReceivedStatusOnClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags)76 void StartServerStreaming(IReceivedStatusOnClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); 77 StartDuplexStreaming(IReceivedStatusOnClientCallback callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags)78 void StartDuplexStreaming(IReceivedStatusOnClientCallback callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags); 79 StartReceiveMessage(IReceivedMessageCallback callback)80 void StartReceiveMessage(IReceivedMessageCallback callback); 81 StartReceiveInitialMetadata(IReceivedResponseHeadersCallback callback)82 void StartReceiveInitialMetadata(IReceivedResponseHeadersCallback callback); 83 StartSendInitialMetadata(ISendCompletionCallback callback, MetadataArraySafeHandle metadataArray)84 void StartSendInitialMetadata(ISendCompletionCallback callback, MetadataArraySafeHandle metadataArray); 85 StartSendMessage(ISendCompletionCallback callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata)86 void StartSendMessage(ISendCompletionCallback callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata); 87 StartSendCloseFromClient(ISendCompletionCallback callback)88 void StartSendCloseFromClient(ISendCompletionCallback callback); 89 StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, byte[] optionalPayload, WriteFlags writeFlags)90 void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, byte[] optionalPayload, WriteFlags writeFlags); 91 StartServerSide(IReceivedCloseOnServerCallback callback)92 void StartServerSide(IReceivedCloseOnServerCallback callback); 93 } 94 } 95