5c35b2ba46111a91c738379e01d9595c73504610
[platform/upstream/grpc.git] / src / csharp / Grpc.Core / Internal / INativeCall.cs
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     {
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     {
31         void OnReceivedStatusOnClient(bool success, ClientSideStatus receivedStatus);
32     }
33
34     internal interface IReceivedMessageCallback
35     {
36         void OnReceivedMessage(bool success, byte[] receivedMessage);
37     }
38
39     internal interface IReceivedResponseHeadersCallback
40     {
41         void OnReceivedResponseHeaders(bool success, Metadata responseHeaders);
42     }
43
44     internal interface ISendCompletionCallback
45     {
46         void OnSendCompletion(bool success);
47     }
48
49     internal interface ISendStatusFromServerCompletionCallback
50     {
51         void OnSendStatusFromServerCompletion(bool success);
52     }
53
54     internal interface IReceivedCloseOnServerCallback
55     {
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     {
64         void Cancel();
65
66         void CancelWithStatus(Status status);
67
68         string GetPeer();
69
70         void StartUnary(IUnaryResponseClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags);
71
72         void StartUnary(BatchContextSafeHandle ctx, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags);
73
74         void StartClientStreaming(IUnaryResponseClientCallback callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags);
75
76         void StartServerStreaming(IReceivedStatusOnClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags);
77
78         void StartDuplexStreaming(IReceivedStatusOnClientCallback callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags);
79
80         void StartReceiveMessage(IReceivedMessageCallback callback);
81
82         void StartReceiveInitialMetadata(IReceivedResponseHeadersCallback callback);
83
84         void StartSendInitialMetadata(ISendCompletionCallback callback, MetadataArraySafeHandle metadataArray);
85
86         void StartSendMessage(ISendCompletionCallback callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata);
87
88         void StartSendCloseFromClient(ISendCompletionCallback callback);
89
90         void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, byte[] optionalPayload, WriteFlags writeFlags);
91
92         void StartServerSide(IReceivedCloseOnServerCallback callback);
93     }
94 }