1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
// **********************************************************************
//
// Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
namespace IceInternal
{
using System.Diagnostics;
public class IncomingAsync : IncomingBase, Ice.AMDCallback
{
public IncomingAsync(Incoming inc)
: base(inc)
{
_retriable = inc.isRetriable();
if(_retriable)
{
inc.setActive(this);
_active = true;
}
}
virtual public void ice_exception(System.Exception ex)
{
//
// Only call exception__ if this incoming is not retriable or if
// all the interceptors return true and no response has been sent
// yet.
//
if(_retriable)
{
try
{
if(interceptorAsyncCallbackList_ != null)
{
foreach(Ice.DispatchInterceptorAsyncCallback cb in interceptorAsyncCallbackList_)
{
if(cb.exception(ex) == false)
{
return;
}
}
}
}
catch(System.Exception)
{
return;
}
lock(this)
{
if(!_active)
{
return;
}
_active = false;
}
}
if(responseHandler_ != null)
{
exception__(ex);
}
else
{
//
// Response has already been sent.
//
if(instance_.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
warning__(ex);
}
}
}
internal void deactivate__(Incoming inc)
{
Debug.Assert(_retriable);
lock(this)
{
if(!_active)
{
//
// Since __deactivate can only be called on an active object,
// this means the response has already been sent (see validateXXX below)
//
throw new Ice.ResponseSentException();
}
_active = false;
}
inc.adopt(this);
}
protected void response__()
{
try
{
if(locator_ != null && !servantLocatorFinished__(true))
{
return;
}
Debug.Assert(responseHandler_ != null);
if(response_)
{
if(observer_ != null)
{
observer_.reply(os_.size() - Protocol.headerSize - 4);
}
responseHandler_.sendResponse(current_.requestId, os_, compress_, true);
}
else
{
responseHandler_.sendNoResponse();
}
if(observer_ != null)
{
observer_.detach();
observer_ = null;
}
responseHandler_ = null;
}
catch(Ice.LocalException ex)
{
responseHandler_.invokeException(current_.requestId, ex, 1, true);
}
}
protected internal void exception__(System.Exception exc)
{
try
{
if(locator_ != null && !servantLocatorFinished__(true))
{
return;
}
handleException__(exc, true);
}
catch(Ice.LocalException ex)
{
responseHandler_.invokeException(current_.requestId, ex, 1, true);
}
}
protected internal BasicStream getOs__()
{
return os_;
}
protected bool validateResponse__(bool ok)
{
//
// Only returns true if this incoming is not retriable or if all
// the interceptors return true and no response has been sent
// yet. Upon getting a true return value, the caller should send
// the response.
//
if(_retriable)
{
try
{
if(interceptorAsyncCallbackList_ != null)
{
foreach(Ice.DispatchInterceptorAsyncCallback cb in interceptorAsyncCallbackList_)
{
if(cb.response(ok) == false)
{
return false;
}
}
}
}
catch(System.Exception)
{
return false;
}
lock(this)
{
if(!_active)
{
return false;
}
_active = false;
}
}
return true;
}
private readonly bool _retriable;
private bool _active = false; // only meaningful when _retriable == true
}
}
namespace Ice
{
/// <summary>
/// Callback interface for Blobject AMD servants.
/// </summary>
public interface AMD_Object_ice_invoke : Ice.AMDCallback
{
/// <summary>
/// Indicates to the Ice run time that an operation
/// completed.
/// </summary>
/// <param name="ok">True indicates that the operation
/// completed successfully; false indicates that the
/// operation raised a user exception.</param>
/// <param name="outEncaps">The encoded out-parameters for the operation or,
/// if ok is false, the encoded user exception.</param>
void ice_response(bool ok, byte[] outEncaps);
}
sealed class _AMD_Object_ice_invoke : IceInternal.IncomingAsync, AMD_Object_ice_invoke
{
public _AMD_Object_ice_invoke(IceInternal.Incoming inc)
: base(inc)
{
}
public void ice_response(bool ok, byte[] outEncaps)
{
try
{
writeParamEncaps__(outEncaps, ok);
}
catch(Ice.LocalException ex)
{
exception__(ex);
return;
}
response__();
}
}
}
|