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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
// **********************************************************************
//
// Copyright (c) 2003-2016 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;
using System.Diagnostics;
using System.Collections.Generic;
sealed class WSEndpoint : EndpointI
{
internal WSEndpoint(ProtocolInstance instance, EndpointI del, string res)
{
_instance = instance;
_delegate = del;
_resource = res;
}
internal WSEndpoint(ProtocolInstance instance, EndpointI del, List<string> args)
{
_instance = instance;
_delegate = del;
initWithOptions(args);
if(_resource == null)
{
_resource = "/";
}
}
internal WSEndpoint(ProtocolInstance instance, EndpointI del, Ice.InputStream s)
{
_instance = instance;
_delegate = del;
_resource = s.readString();
}
private sealed class InfoI : Ice.WSEndpointInfo
{
public InfoI(EndpointI e)
{
_endpoint = e;
}
override public short type()
{
return _endpoint.type();
}
override public bool datagram()
{
return _endpoint.datagram();
}
override public bool secure()
{
return _endpoint.secure();
}
private EndpointI _endpoint;
}
public override Ice.EndpointInfo getInfo()
{
Ice.WSEndpointInfo info = new InfoI(this);
info.underlying = _delegate.getInfo();
info.resource = _resource;
info.compress = info.underlying.compress;
info.timeout = info.underlying.timeout;
return info;
}
public override short type()
{
return _delegate.type();
}
public override string protocol()
{
return _delegate.protocol();
}
public override void streamWriteImpl(Ice.OutputStream s)
{
_delegate.streamWriteImpl(s);
s.writeString(_resource);
}
public override int timeout()
{
return _delegate.timeout();
}
public override EndpointI timeout(int timeout)
{
if(timeout == _delegate.timeout())
{
return this;
}
else
{
return new WSEndpoint(_instance, _delegate.timeout(timeout), _resource);
}
}
public override string connectionId()
{
return _delegate.connectionId();
}
public override EndpointI connectionId(string connectionId)
{
if(connectionId.Equals(_delegate.connectionId()))
{
return this;
}
else
{
return new WSEndpoint(_instance, _delegate.connectionId(connectionId), _resource);
}
}
public override bool compress()
{
return _delegate.compress();
}
public override EndpointI compress(bool compress)
{
if(compress == _delegate.compress())
{
return this;
}
else
{
return new WSEndpoint(_instance, _delegate.compress(compress), _resource);
}
}
public override bool datagram()
{
return _delegate.datagram();
}
public override bool secure()
{
return _delegate.secure();
}
public override Transceiver transceiver()
{
return null;
}
private sealed class EndpointI_connectorsI : EndpointI_connectors
{
public EndpointI_connectorsI(ProtocolInstance instance, string host, string res, EndpointI_connectors cb)
{
_instance = instance;
_host = host;
_resource = res;
_callback = cb;
}
public void connectors(List<Connector> connectors)
{
List<Connector> l = new List<Connector>();
foreach(Connector c in connectors)
{
l.Add(new WSConnector(_instance, c, _host, _resource));
}
_callback.connectors(l);
}
public void exception(Ice.LocalException ex)
{
_callback.exception(ex);
}
private ProtocolInstance _instance;
private string _host;
private string _resource;
private EndpointI_connectors _callback;
}
public override void connectors_async(Ice.EndpointSelectionType selType, EndpointI_connectors callback)
{
string host = "";
for(Ice.EndpointInfo p = _delegate.getInfo(); p != null; p = p.underlying)
{
if(p is Ice.IPEndpointInfo)
{
Ice.IPEndpointInfo ipInfo = (Ice.IPEndpointInfo)p;
host = ipInfo.host + ":" + ipInfo.port;
}
}
_delegate.connectors_async(selType, new EndpointI_connectorsI(_instance, host, _resource, callback));
}
public override Acceptor acceptor(string adapterName)
{
return new WSAcceptor(this, _instance, _delegate.acceptor(adapterName));
}
public WSEndpoint endpoint(EndpointI delEndp)
{
return new WSEndpoint(_instance, delEndp, _resource);
}
public override List<EndpointI> expand()
{
List<EndpointI> endps = _delegate.expand();
List<EndpointI> l = new List<EndpointI>();
foreach(EndpointI e in endps)
{
l.Add(e == _delegate ? this : new WSEndpoint(_instance, e, _resource));
}
return l;
}
public override bool equivalent(EndpointI endpoint)
{
if(!(endpoint is WSEndpoint))
{
return false;
}
WSEndpoint wsEndpointI = (WSEndpoint)endpoint;
return _delegate.equivalent(wsEndpointI._delegate);
}
public override string options()
{
//
// WARNING: Certain features, such as proxy validation in Glacier2,
// depend on the format of proxy strings. Changes to toString() and
// methods called to generate parts of the reference string could break
// these features. Please review for all features that depend on the
// format of proxyToString() before changing this and related code.
//
string s = _delegate.options();
if(_resource != null && _resource.Length > 0)
{
s += " -r ";
bool addQuote = _resource.IndexOf(':') != -1;
if(addQuote)
{
s += "\"";
}
s += _resource;
if(addQuote)
{
s += "\"";
}
}
return s;
}
public override int GetHashCode()
{
int h = _delegate.GetHashCode();
HashUtil.hashAdd(ref h, _resource);
return h;
}
public override int CompareTo(EndpointI obj)
{
if(!(obj is EndpointI))
{
return type() < obj.type() ? -1 : 1;
}
WSEndpoint p = (WSEndpoint)obj;
if(this == p)
{
return 0;
}
int v = string.Compare(_resource, p._resource, StringComparison.Ordinal);
if(v != 0)
{
return v;
}
return _delegate.CompareTo(p._delegate);
}
protected override bool checkOption(string option, string argument, string endpoint)
{
switch(option[1])
{
case 'r':
{
if(argument == null)
{
Ice.EndpointParseException e = new Ice.EndpointParseException();
e.str = "no argument provided for -r option in endpoint " + endpoint + _delegate.options();
throw e;
}
_resource = argument;
return true;
}
default:
{
return false;
}
}
}
private ProtocolInstance _instance;
private EndpointI _delegate;
private string _resource;
}
public class WSEndpointFactory : EndpointFactory
{
public WSEndpointFactory(ProtocolInstance instance, EndpointFactory del)
{
_instance = instance;
_delegate = del;
}
public short type()
{
return _instance.type();
}
public string protocol()
{
return _instance.protocol();
}
public EndpointI create(List<string> args, bool oaEndpoint)
{
return new WSEndpoint(_instance, _delegate.create(args, oaEndpoint), args);
}
public EndpointI read(Ice.InputStream s)
{
return new WSEndpoint(_instance, _delegate.read(s), s);
}
public void destroy()
{
_delegate.destroy();
_instance = null;
}
public EndpointFactory clone(ProtocolInstance instance, EndpointFactory del)
{
return new WSEndpointFactory(instance, del);
}
private ProtocolInstance _instance;
private EndpointFactory _delegate;
}
}
|