// ********************************************************************** // // 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. // // ********************************************************************** using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using IceUtilInternal; using Ice.Instrumentation; namespace Ice { /// /// Delegate for a successful ice_isA invocation. /// True if the remote object supports the type, false otherwise. /// public delegate void Callback_Object_ice_isA(bool ret__); /// /// Delegate for a successful ice_ids invocation. /// The array of Slice type ids supported by the remote object. /// public delegate void Callback_Object_ice_ids(string[] ret__); /// /// Delegate for a successful ice_id invocation. /// The Slice type id of the most-derived interface supported by the remote object. /// public delegate void Callback_Object_ice_id(string ret__); /// /// Delegate for a successful ice_ping invocation. /// public delegate void Callback_Object_ice_ping(); /// /// Delegate for a successful ice_invoke invocation. /// True if the invocation succeeded, or false if the invocation /// raised a user exception. /// The encoded out-parameters or user exception. /// public delegate void Callback_Object_ice_invoke(bool ret__, byte[] outEncaps); /// /// Delegate for a successful ice_getConnection invocation. /// The connection used by the proxy. /// public delegate void Callback_Object_ice_getConnection(Connection ret__); /// /// Base interface of all object proxies. /// public interface ObjectPrx { /// /// Returns the communicator that created this proxy. /// /// The communicator that created this proxy. Communicator ice_getCommunicator(); /// /// Tests whether this object supports a specific Slice interface. /// /// The type ID of the Slice interface to test against. /// True if the target object has the interface specified by id__ or derives /// from the interface specified by id__. bool ice_isA(string id__); /// /// Tests whether this object supports a specific Slice interface. /// /// The type ID of the Slice interface to test against. /// The context dictionary for the invocation. /// True if the target object has the interface specified by id__ or derives /// from the interface specified by id__. bool ice_isA(string id__, Dictionary context__); /// /// Tests whether this object supports a specific Slice interface. /// /// The type ID of the Slice interface to test against. /// An asynchronous result object. AsyncResult begin_ice_isA(string id); /// /// Tests whether this object supports a specific Slice interface. /// /// The type ID of the Slice interface to test against. /// The context dictionary for the invocation. /// An asynchronous result object. AsyncResult begin_ice_isA(string id, Dictionary context__); /// /// Tests whether this object supports a specific Slice interface. /// /// The type ID of the Slice interface to test against. /// A callback to be invoked when the invocation completes. /// Application-specific data to be stored in the result. /// An asynchronous result object. AsyncResult begin_ice_isA(string id, AsyncCallback cb__, object cookie__); /// /// Tests whether this object supports a specific Slice interface. /// /// The type ID of the Slice interface to test against. /// The context dictionary for the invocation. /// A callback to be invoked when the invocation completes. /// Application-specific data to be stored in the result. /// An asynchronous result object. AsyncResult begin_ice_isA(string id, Dictionary context__, AsyncCallback cb__, object cookie__); /// /// Tests whether this object supports a specific Slice interface. /// /// The asynchronous result object returned by begin_ice_isA. /// True if the object supports the Slice interface, false otherwise. bool end_ice_isA(AsyncResult r__); /// /// Tests whether the target object of this proxy can be reached. /// void ice_ping(); /// /// Tests whether the target object of this proxy can be reached. /// /// The context dictionary for the invocation. void ice_ping(Dictionary context__); /// /// Tests whether the target object of this proxy can be reached. /// /// An asynchronous result object. AsyncResult begin_ice_ping(); /// /// Tests whether the target object of this proxy can be reached. /// /// The context dictionary for the invocation. /// An asynchronous result object. AsyncResult begin_ice_ping(Dictionary context__); /// /// Tests whether the target object of this proxy can be reached. /// /// A callback to be invoked when the invocation completes. /// Application-specific data to be stored in the result. /// An asynchronous result object. AsyncResult begin_ice_ping(AsyncCallback cb__, object cookie__); /// /// Tests whether the target object of this proxy can be reached. /// /// The context dictionary for the invocation. /// A callback to be invoked when the invocation completes. /// Application-specific data to be stored in the result. /// An asynchronous result object. AsyncResult begin_ice_ping(Dictionary context__, AsyncCallback cb__, object cookie__); /// /// Tests whether the target object of this proxy can be reached. /// /// The asynchronous result object returned by begin_ice_ping. void end_ice_ping(AsyncResult r__); /// /// Returns the Slice type IDs of the interfaces supported by the target object of this proxy. /// /// The Slice type IDs of the interfaces supported by the target object, in base-to-derived /// order. The first element of the returned array is always ::Ice::Object. string[] ice_ids(); /// /// Returns the Slice type IDs of the interfaces supported by the target object of this proxy. /// /// The context dictionary for the invocation. /// The Slice type IDs of the interfaces supported by the target object, in base-to-derived /// order. The first element of the returned array is always ::Ice::Object. string[] ice_ids(Dictionary context__); /// /// Returns the Slice type IDs of the interfaces supported by the target object of this proxy. /// /// An asynchronous result object. AsyncResult begin_ice_ids(); /// /// Returns the Slice type IDs of the interfaces supported by the target object of this proxy. /// /// The context dictionary for the invocation. /// An asynchronous result object. AsyncResult begin_ice_ids(Dictionary context__); /// /// Returns the Slice type IDs of the interfaces supported by the target object of this proxy. /// /// A callback to be invoked when the invocation completes. /// Application-specific data to be stored in the result. /// An asynchronous result object. AsyncResult begin_ice_ids(AsyncCallback cb__, object cookie__); /// /// Returns the Slice type IDs of the interfaces supported by the target object of this proxy. /// /// The context dictionary for the invocation. /// A callback to be invoked when the invocation completes. /// Application-specific data to be stored in the result. /// An asynchronous result object. AsyncResult begin_ice_ids(Dictionary context__, AsyncCallback cb__, object cookie__); /// /// Returns the Slice type IDs of the interfaces supported by the target object of this proxy. /// /// The asynchronous result object returned by begin_ice_ids. /// The Slice type IDs of the interfaces supported by the target object, in base-to-derived /// order. The first element of the returned array is always ::Ice::Object. string[] end_ice_ids(AsyncResult r__); /// /// Returns the Slice type ID of the most-derived interface supported by the target object of this proxy. /// /// The Slice type ID of the most-derived interface. string ice_id(); /// /// Returns the Slice type ID of the most-derived interface supported by the target object of this proxy. /// /// The context dictionary for the invocation. /// The Slice type ID of the most-derived interface. string ice_id(Dictionary context__); /// /// Returns the Slice type ID of the most-derived interface supported by the target object of this proxy. /// /// An asynchronous result object. AsyncResult begin_ice_id(); /// /// Returns the Slice type ID of the most-derived interface supported by the target object of this proxy. /// /// The context dictionary for the invocation. /// An asynchronous result object. AsyncResult begin_ice_id(Dictionary context__); /// /// Returns the Slice type ID of the most-derived interface supported by the target object of this proxy. /// /// A callback to be invoked when the invocation completes. /// Application-specific data to be stored in the result. /// An asynchronous result object. AsyncResult begin_ice_id(AsyncCallback cb__, object cookie__); /// /// Returns the Slice type ID of the most-derived interface supported by the target object of this proxy. /// /// The context dictionary for the invocation. /// A callback to be invoked when the invocation completes. /// Application-specific data to be stored in the result. /// An asynchronous result object. AsyncResult begin_ice_id(Dictionary context__, AsyncCallback cb__, object cookie__); /// /// Returns the Slice type ID of the most-derived interface supported by the target object of this proxy. /// /// The asynchronous result object returned by begin_ice_id. /// The Slice type ID of the most-derived interface. string end_ice_id(AsyncResult r__); /// /// Invokes an operation dynamically. /// /// The name of the operation to invoke. /// The operation mode (normal or idempotent). /// The encoded in-parameters for the operation. /// The encoded out-paramaters and return value /// for the operation. The return value follows any out-parameters. /// If the operation completed successfully, the return value /// is true. If the operation raises a user exception, /// the return value is false; in this case, outEncaps /// contains the encoded user exception. If the operation raises a run-time exception, /// it throws it directly. bool ice_invoke(string operation, OperationMode mode, byte[] inEncaps, out byte[] outEncaps); /// /// Invokes an operation dynamically. /// /// The name of the operation to invoke. /// The operation mode (normal or idempotent). /// The encoded in-parameters for the operation. /// The encoded out-paramaters and return value /// for the operation. The return value follows any out-parameters. /// The context dictionary for the invocation. /// If the operation completed successfully, the return value /// is true. If the operation raises a user exception, /// the return value is false; in this case, outEncaps /// contains the encoded user exception. If the operation raises a run-time exception, /// it throws it directly. bool ice_invoke(string operation, OperationMode mode, byte[] inEncaps, out byte[] outEncaps, Dictionary context__); /// /// Invokes an operation dynamically. /// /// The name of the operation to invoke. /// The operation mode (normal or idempotent). /// The encoded in-parameters for the operation. /// An asynchronous result object. AsyncResult begin_ice_invoke(string operation, OperationMode mode, byte[] inEncaps); /// /// Invokes an operation dynamically. /// /// The name of the operation to invoke. /// The operation mode (normal or idempotent). /// The encoded in-parameters for the operation. /// The context dictionary for the invocation. /// An asynchronous result object. AsyncResult begin_ice_invoke(string operation, OperationMode mode, byte[] inEncaps, Dictionary context__); /// /// Invokes an operation dynamically. /// /// The name of the operation to invoke. /// The operation mode (normal or idempotent). /// The encoded in-parameters for the operation. /// A callback to be invoked when the invocation completes. /// Application-specific data to be stored in the result. /// An asynchronous result object. AsyncResult begin_ice_invoke(string operation, OperationMode mode, byte[] inEncaps, AsyncCallback cb__, object cookie__); /// /// Invokes an operation dynamically. /// /// The name of the operation to invoke. /// The operation mode (normal or idempotent). /// The encoded in-parameters for the operation. /// The context dictionary for the invocation. /// A callback to be invoked when the invocation completes. /// Application-specific data to be stored in the result. /// An asynchronous result object. AsyncResult begin_ice_invoke(string operation, OperationMode mode, byte[] inEncaps, Dictionary context__, AsyncCallback cb__, object cookie__); /// /// Completes a dynamic invocation. /// /// The encoded out parameters or user exception. /// The asynchronous result object returned by begin_ice_invoke. /// If the operation completed successfully, the return value /// is true. If the operation raises a user exception, /// the return value is false; in this case, outEncaps /// contains the encoded user exception. If the operation raises a run-time exception, /// it throws it directly. bool end_ice_invoke(out byte[] outEncaps, AsyncResult r__); /// /// Returns the identity embedded in this proxy. /// The identity of the target object. /// Identity ice_getIdentity(); /// /// Creates a new proxy that is identical to this proxy, except for the per-proxy context. /// The identity for the new proxy. /// The proxy with the new identity. /// ObjectPrx ice_identity(Identity newIdentity); /// /// Returns the per-proxy context for this proxy. /// /// The per-proxy context. If the proxy does not have a per-proxy (implicit) context, the return value /// is null. Dictionary ice_getContext(); /// /// Creates a new proxy that is identical to this proxy, except for the per-proxy context. /// /// The context for the new proxy. /// The proxy with the new per-proxy context. ObjectPrx ice_context(Dictionary newContext); /// /// Returns the facet for this proxy. /// /// The facet for this proxy. If the proxy uses the default facet, the return value is the /// empty string. string ice_getFacet(); /// /// Creates a new proxy that is identical to this proxy, except for the facet. /// /// The facet for the new proxy. /// The proxy with the new facet. ObjectPrx ice_facet(string newFacet); /// /// Returns the adapter ID for this proxy. /// /// The adapter ID. If the proxy does not have an adapter ID, the return value is the /// empty string. string ice_getAdapterId(); /// /// Creates a new proxy that is identical to this proxy, except for the adapter ID. /// /// The adapter ID for the new proxy. /// The proxy with the new adapter ID. ObjectPrx ice_adapterId(string newAdapterId); /// /// Returns the endpoints used by this proxy. /// /// The endpoints used by this proxy. Endpoint[] ice_getEndpoints(); /// /// Creates a new proxy that is identical to this proxy, except for the endpoints. /// /// The endpoints for the new proxy. /// The proxy with the new endpoints. ObjectPrx ice_endpoints(Endpoint[] newEndpoints); /// /// Returns the locator cache timeout of this proxy. /// /// The locator cache timeout value (in seconds). int ice_getLocatorCacheTimeout(); /// /// Creates a new proxy that is identical to this proxy, except for the locator cache timeout. /// /// The new locator cache timeout (in seconds). ObjectPrx ice_locatorCacheTimeout(int timeout); /// /// Creates a new proxy that is identical to this proxy, except for the invocation timeout. /// /// The new invocation timeout (in seconds). ObjectPrx ice_invocationTimeout(int timeout); /// /// Returns the invocation timeout of this proxy. /// /// The invocation timeout value (in seconds). int ice_getInvocationTimeout(); /// /// Returns whether this proxy caches connections. /// /// True if this proxy caches connections; false, otherwise. bool ice_isConnectionCached(); /// /// Creates a new proxy that is identical to this proxy, except for connection caching. /// /// True if the new proxy should cache connections; false, otherwise. /// The new proxy with the specified caching policy. ObjectPrx ice_connectionCached(bool newCache); /// /// Returns how this proxy selects endpoints (randomly or ordered). /// /// The endpoint selection policy. EndpointSelectionType ice_getEndpointSelection(); /// /// Creates a new proxy that is identical to this proxy, except for the endpoint selection policy. /// /// The new endpoint selection policy. /// The new proxy with the specified endpoint selection policy. ObjectPrx ice_endpointSelection(EndpointSelectionType newType); /// /// Returns whether this proxy communicates only via secure endpoints. /// /// True if this proxy communicates only vi secure endpoints; false, otherwise. bool ice_isSecure(); /// /// Creates a new proxy that is identical to this proxy, except for how it selects endpoints. /// /// If b is true, only endpoints that use a secure transport are /// used by the new proxy. If b is false, the returned proxy uses both secure and insecure /// endpoints. /// The new proxy with the specified selection policy. ObjectPrx ice_secure(bool b); /// /// Creates a new proxy that is identical to this proxy, except for the encoding used to marshal /// parameters. /// /// The encoding version to use to marshal requests parameters. /// The new proxy with the specified encoding version. ObjectPrx ice_encodingVersion(Ice.EncodingVersion e); /// Returns the encoding version used to marshal requests parameters. /// The encoding version. Ice.EncodingVersion ice_getEncodingVersion(); /// /// Returns whether this proxy prefers secure endpoints. /// /// True if the proxy always attempts to invoke via secure endpoints before it /// attempts to use insecure endpoints; false, otherwise. bool ice_isPreferSecure(); /// /// Creates a new proxy that is identical to this proxy, except for its endpoint selection policy. /// /// If b is true, the new proxy will use secure endpoints for invocations /// and only use insecure endpoints if an invocation cannot be made via secure endpoints. If b is /// false, the proxy prefers insecure endpoints to secure ones. /// The new proxy with the new endpoint selection policy. ObjectPrx ice_preferSecure(bool b); /// /// Returns the router for this proxy. /// /// The router for the proxy. If no router is configured for the proxy, the return value /// is null. Ice.RouterPrx ice_getRouter(); /// /// Creates a new proxy that is identical to this proxy, except for the router. /// /// The router for the new proxy. /// The new proxy with the specified router. ObjectPrx ice_router(Ice.RouterPrx router); /// /// Returns the locator for this proxy. /// /// The locator for this proxy. If no locator is configured, the return value is null. Ice.LocatorPrx ice_getLocator(); /// /// Creates a new proxy that is identical to this proxy, except for the locator. /// /// The locator for the new proxy. /// The new proxy with the specified locator. ObjectPrx ice_locator(Ice.LocatorPrx locator); /// /// Returns whether this proxy uses collocation optimization. /// /// True if the proxy uses collocation optimization; false, otherwise. bool ice_isCollocationOptimized(); /// /// Creates a new proxy that is identical to this proxy, except for collocation optimization. /// /// True if the new proxy enables collocation optimization; false, otherwise. /// The new proxy the specified collocation optimization. ObjectPrx ice_collocationOptimized(bool b); /// /// Creates a new proxy that is identical to this proxy, but uses twoway invocations. /// /// A new proxy that uses twoway invocations. ObjectPrx ice_twoway(); /// /// Returns whether this proxy uses twoway invocations. /// /// True if this proxy uses twoway invocations; false, otherwise. bool ice_isTwoway(); /// /// Creates a new proxy that is identical to this proxy, but uses oneway invocations. /// /// A new proxy that uses oneway invocations. ObjectPrx ice_oneway(); /// /// Returns whether this proxy uses oneway invocations. /// /// True if this proxy uses oneway invocations; false, otherwise. bool ice_isOneway(); /// /// Creates a new proxy that is identical to this proxy, but uses batch oneway invocations. /// /// A new proxy that uses batch oneway invocations. ObjectPrx ice_batchOneway(); /// /// Returns whether this proxy uses batch oneway invocations. /// /// True if this proxy uses batch oneway invocations; false, otherwise. bool ice_isBatchOneway(); /// /// Creates a new proxy that is identical to this proxy, but uses datagram invocations. /// /// A new proxy that uses datagram invocations. ObjectPrx ice_datagram(); /// /// Returns whether this proxy uses datagram invocations. /// /// True if this proxy uses datagram invocations; false, otherwise. bool ice_isDatagram(); /// /// Creates a new proxy that is identical to this proxy, but uses batch datagram invocations. /// /// A new proxy that uses batch datagram invocations. ObjectPrx ice_batchDatagram(); /// /// Returns whether this proxy uses batch datagram invocations. /// /// True if this proxy uses batch datagram invocations; false, otherwise. bool ice_isBatchDatagram(); /// /// Creates a new proxy that is identical to this proxy, except for compression. /// /// True enables compression for the new proxy; false disables compression. /// A new proxy with the specified compression setting. ObjectPrx ice_compress(bool co); /// /// Creates a new proxy that is identical to this proxy, except for its timeout setting. /// /// The timeout for the new proxy in milliseconds. /// A new proxy with the specified timeout. ObjectPrx ice_timeout(int t); /// /// Creates a new proxy that is identical to this proxy, except for its connection ID. /// /// The connection ID for the new proxy. An empty string removes the /// connection ID. /// A new proxy with the specified connection ID. ObjectPrx ice_connectionId(string connectionId); /// /// Returns the connection id of this proxy. /// /// The connection id. string ice_getConnectionId(); /// /// Returns the Connection for this proxy. If the proxy does not yet have an established connection, /// it first attempts to create a connection. /// /// The Connection for this proxy. /// If the proxy uses collocation optimization and denotes a /// collocated object. Connection ice_getConnection(); /// /// Asynchronously gets the connection for this proxy. /// /// An asynchronous result object. AsyncResult begin_ice_getConnection(); /// /// Asynchronously gets the connection for this proxy. /// /// A callback to be invoked when the invocation completes. /// Application-specific data to be stored in the result. /// An asynchronous result object. AsyncResult begin_ice_getConnection(AsyncCallback cb__, object cookie__); /// /// Asynchronously gets the connection for this proxy. /// /// The asynchronous result object returned by begin_ice_getConnection. /// The connection. Connection end_ice_getConnection(AsyncResult r__); /// /// Returns the cached Connection for this proxy. If the proxy does not yet have an established /// connection, it does not attempt to create a connection. /// /// The cached Connection for this proxy (null if the proxy does not have /// an established connection). /// If the proxy uses collocation optimization and denotes a /// collocated object. Connection ice_getCachedConnection(); /// /// Flushes any pending batched requests for this communicator. The call blocks until the flush is complete. /// void ice_flushBatchRequests(); AsyncResult begin_ice_flushBatchRequests(); AsyncResult begin_ice_flushBatchRequests(AsyncCallback cb__, object cookie__); void end_ice_flushBatchRequests(AsyncResult r__); } /// /// Base class of all object proxies. /// public class ObjectPrxHelperBase : ObjectPrx { /// /// Returns a hash code for this proxy. /// /// The hash code. public override int GetHashCode() { return _reference.GetHashCode(); } /// /// Returns the communicator that created this proxy. /// /// The communicator that created this proxy. public Communicator ice_getCommunicator() { return _reference.getCommunicator(); } /// /// Returns the stringified form of this proxy. /// /// The stringified proxy. public override string ToString() { return _reference.ToString(); } /// /// Tests whether this object supports a specific Slice interface. /// /// The type ID of the Slice interface to test against. /// True if the target object has the interface specified by id__ or derives /// from the interface specified by id__. public bool ice_isA(string id__) { return ice_isA(id__, null, false); } /// /// Tests whether this object supports a specific Slice interface. /// /// The type ID of the Slice interface to test against. /// The context dictionary for the invocation. /// True if the target object has the interface specified by id__ or derives /// from the interface specified by id__. public bool ice_isA(string id__, Dictionary context__) { return ice_isA(id__, context__, true); } private bool ice_isA(string id__, Dictionary context__, bool explicitCtx__) { checkTwowayOnly__(__ice_isA_name); return end_ice_isA(begin_ice_isA(id__, context__, explicitCtx__, true, null, null)); } public AsyncResult begin_ice_isA(string id) { return begin_ice_isA(id, null, false, false, null, null); } public AsyncResult begin_ice_isA(string id, Dictionary context__) { return begin_ice_isA(id, context__, true, false, null, null); } public AsyncResult begin_ice_isA(string id, AsyncCallback cb__, object cookie__) { return begin_ice_isA(id, null, false, false, cb__, cookie__); } public AsyncResult begin_ice_isA(string id, Dictionary context__, AsyncCallback cb__, object cookie__) { return begin_ice_isA(id, context__, true, false, cb__, cookie__); } internal const string __ice_isA_name = "ice_isA"; public bool end_ice_isA(AsyncResult r__) { IceInternal.OutgoingAsync outAsync__ = IceInternal.OutgoingAsync.check(r__, this, __ice_isA_name); try { if(!outAsync__.wait()) { try { outAsync__.throwUserException(); } catch(Ice.UserException ex__) { throw new Ice.UnknownUserException(ex__.ice_name(), ex__); } } bool ret__; IceInternal.BasicStream is__ = outAsync__.startReadParams(); ret__ = is__.readBool(); outAsync__.endReadParams(); return ret__; } finally { if(outAsync__ != null) { outAsync__.cacheMessageBuffers(); } } } private AsyncResult begin_ice_isA(string id, Dictionary context__, bool explicitCtx__, bool synchronous__, Ice.AsyncCallback cb__, object cookie__) { checkAsyncTwowayOnly__(__ice_isA_name); IceInternal.TwowayOutgoingAsync result__ = getTwowayOutgoingAsync(__ice_isA_name, ice_isA_completed__, cookie__); if(cb__ != null) { result__.whenCompletedWithAsyncCallback(cb__); } try { result__.prepare(__ice_isA_name, OperationMode.Nonmutating, context__, explicitCtx__, synchronous__); IceInternal.BasicStream os__ = result__.startWriteParams(FormatType.DefaultFormat); os__.writeString(id); result__.endWriteParams(); result__.invoke(); } catch(Ice.Exception ex__) { result__.abort(ex__); } return result__; } protected IceInternal.TwowayOutgoingAsync getTwowayOutgoingAsync(string operation, IceInternal.ProxyTwowayCallback cb, object cookie) { bool haveEntry = false; IceInternal.BasicStream iss = null; IceInternal.BasicStream os = null; if(_reference.getInstance().cacheMessageBuffers() > 0) { lock(this) { if(_streamCache != null && _streamCache.Count > 0) { haveEntry = true; iss = _streamCache.First.Value.iss; os = _streamCache.First.Value.os; _streamCache.RemoveFirst(); } } } if(!haveEntry) { return new IceInternal.TwowayOutgoingAsync(this, operation, cb, cookie); } else { return new IceInternal.TwowayOutgoingAsync(this, operation, cb, cookie, iss, os); } } protected IceInternal.OnewayOutgoingAsync getOnewayOutgoingAsync(string operation, IceInternal.ProxyOnewayCallback cb, object cookie) { bool haveEntry = false; IceInternal.BasicStream iss = null; IceInternal.BasicStream os = null; if(_reference.getInstance().cacheMessageBuffers() > 0) { lock(this) { if(_streamCache != null && _streamCache.Count > 0) { haveEntry = true; iss = _streamCache.First.Value.iss; os = _streamCache.First.Value.os; _streamCache.RemoveFirst(); } } } if(!haveEntry) { return new IceInternal.OnewayOutgoingAsync(this, operation, cb, cookie); } else { return new IceInternal.OnewayOutgoingAsync(this, operation, cb, cookie, iss, os); } } public void cacheMessageBuffers(IceInternal.BasicStream iss, IceInternal.BasicStream os) { lock(this) { if(_streamCache == null) { _streamCache = new LinkedList(); } StreamCacheEntry cacheEntry; cacheEntry.iss = iss; cacheEntry.os = os; _streamCache.AddLast(cacheEntry); } } private void ice_isA_completed__(AsyncResult r__, Callback_Object_ice_isA cb__, Ice.ExceptionCallback excb__) { bool ret__; try { ret__ = end_ice_isA(r__); } catch(Ice.Exception ex__) { if(excb__ != null) { excb__(ex__); } return; } if(cb__ != null) { cb__(ret__); } } /// /// Tests whether the target object of this proxy can be reached. /// public void ice_ping() { ice_ping(null, false); } /// /// Tests whether the target object of this proxy can be reached. /// /// The context dictionary for the invocation. public void ice_ping(Dictionary context__) { ice_ping(context__, true); } private void ice_ping(Dictionary context__, bool explicitCtx__) { end_ice_ping(begin_ice_ping(context__, explicitCtx__, true, null, null)); } public AsyncResult begin_ice_ping() { return begin_ice_ping(null, false, false, null, null); } public AsyncResult begin_ice_ping(Dictionary context__) { return begin_ice_ping(context__, true, false, null, null); } public AsyncResult begin_ice_ping(AsyncCallback cb__, object cookie__) { return begin_ice_ping(null, false, false, cb__, cookie__); } public AsyncResult begin_ice_ping(Dictionary context__, AsyncCallback cb__, object cookie__) { return begin_ice_ping(null, false, false, cb__, cookie__); } internal const string __ice_ping_name = "ice_ping"; public void end_ice_ping(AsyncResult r__) { end__(r__, __ice_ping_name); } private AsyncResult begin_ice_ping(Dictionary context__, bool explicitCtx__, bool synchronous__, Ice.AsyncCallback cb__, object cookie__) { IceInternal.OnewayOutgoingAsync result__ = getOnewayOutgoingAsync(__ice_ping_name, ice_ping_completed__, cookie__); if(cb__ != null) { result__.whenCompletedWithAsyncCallback(cb__); } try { result__.prepare(__ice_ping_name, OperationMode.Nonmutating, context__, explicitCtx__, synchronous__); result__.writeEmptyParams(); result__.invoke(); } catch(Ice.Exception ex__) { result__.abort(ex__); } return result__; } private void ice_ping_completed__(Callback_Object_ice_ping cb) { if(cb != null) { cb(); } } /// /// Returns the Slice type IDs of the interfaces supported by the target object of this proxy. /// /// The Slice type IDs of the interfaces supported by the target object, in base-to-derived /// order. The first element of the returned array is always ::Ice::Object. public string[] ice_ids() { return ice_ids(null, false); } /// /// Returns the Slice type IDs of the interfaces supported by the target object of this proxy. /// /// The context dictionary for the invocation. /// The Slice type IDs of the interfaces supported by the target object, in base-to-derived /// order. The first element of the returned array is always ::Ice::Object. public string[] ice_ids(Dictionary context__) { return ice_ids(context__, true); } private string[] ice_ids(Dictionary context__, bool explicitCtx__) { checkTwowayOnly__(__ice_ids_name); return end_ice_ids(begin_ice_ids(context__, explicitCtx__, true, null, null)); } public AsyncResult begin_ice_ids() { return begin_ice_ids(null, false, false, null, null); } public AsyncResult begin_ice_ids(Dictionary context__) { return begin_ice_ids(context__, true, false, null, null); } public AsyncResult begin_ice_ids(AsyncCallback cb__, object cookie__) { return begin_ice_ids(null, false, false, cb__, cookie__); } public AsyncResult begin_ice_ids(Dictionary context__, AsyncCallback cb__, object cookie__) { return begin_ice_ids(null, false, false, cb__, cookie__); } internal const string __ice_ids_name = "ice_ids"; public string[] end_ice_ids(AsyncResult r__) { IceInternal.OutgoingAsync outAsync__ = IceInternal.OutgoingAsync.check(r__, this, __ice_ids_name); try { if(!outAsync__.wait()) { try { outAsync__.throwUserException(); } catch(Ice.UserException ex__) { throw new Ice.UnknownUserException(ex__.ice_name(), ex__); } } string[] ret__; IceInternal.BasicStream is__ = outAsync__.startReadParams(); ret__ = is__.readStringSeq(); outAsync__.endReadParams(); return ret__; } finally { if(outAsync__ != null) { outAsync__.cacheMessageBuffers(); } } } private AsyncResult begin_ice_ids(Dictionary context__, bool explicitCtx__, bool synchronous__, Ice.AsyncCallback cb__, object cookie__) { checkAsyncTwowayOnly__(__ice_ids_name); IceInternal.TwowayOutgoingAsync result__ = getTwowayOutgoingAsync(__ice_ids_name, ice_ids_completed__, cookie__); if(cb__ != null) { result__.whenCompletedWithAsyncCallback(cb__); } try { result__.prepare(__ice_ids_name, OperationMode.Nonmutating, context__, explicitCtx__, synchronous__); result__.writeEmptyParams(); result__.invoke(); } catch(Ice.Exception ex__) { result__.abort(ex__); } return result__; } private void ice_ids_completed__(AsyncResult r__, Callback_Object_ice_ids cb__, Ice.ExceptionCallback excb__) { string[] ret__; try { ret__ = end_ice_ids(r__); } catch(Ice.Exception ex__) { if(excb__ != null) { excb__(ex__); } return; } if(cb__ != null) { cb__(ret__); } } /// /// Returns the Slice type ID of the most-derived interface supported by the target object of this proxy. /// /// The Slice type ID of the most-derived interface. public string ice_id() { return ice_id(null, false); } /// /// Returns the Slice type ID of the most-derived interface supported by the target object of this proxy. /// /// The context dictionary for the invocation. /// The Slice type ID of the most-derived interface. public string ice_id(Dictionary context__) { return ice_id(context__, true); } private string ice_id(Dictionary context__, bool explicitCtx__) { checkTwowayOnly__(__ice_id_name); return end_ice_id(begin_ice_id(context__, explicitCtx__, true, null, null)); } public AsyncResult begin_ice_id() { return begin_ice_id(null, false, false, null, null); } public AsyncResult begin_ice_id(Dictionary context__) { return begin_ice_id(context__, true, false, null, null); } public AsyncResult begin_ice_id(AsyncCallback cb__, object cookie__) { return begin_ice_id(null, false, false, cb__, cookie__); } public AsyncResult begin_ice_id(Dictionary context__, AsyncCallback cb__, object cookie__) { return begin_ice_id(null, false, false, cb__, cookie__); } internal const string __ice_id_name = "ice_id"; public string end_ice_id(AsyncResult r__) { IceInternal.OutgoingAsync outAsync__ = IceInternal.OutgoingAsync.check(r__, this, __ice_id_name); try { if(!outAsync__.wait()) { try { outAsync__.throwUserException(); } catch(Ice.UserException ex__) { throw new Ice.UnknownUserException(ex__.ice_name(), ex__); } } string ret__; IceInternal.BasicStream is__ = outAsync__.startReadParams(); ret__ = is__.readString(); outAsync__.endReadParams(); return ret__; } finally { if(outAsync__ != null) { outAsync__.cacheMessageBuffers(); } } } private AsyncResult begin_ice_id(Dictionary context__, bool explicitCtx__, bool synchronous__, Ice.AsyncCallback cb__, object cookie__) { checkAsyncTwowayOnly__(__ice_id_name); IceInternal.TwowayOutgoingAsync result__ = getTwowayOutgoingAsync(__ice_id_name, ice_id_completed__, cookie__); if(cb__ != null) { result__.whenCompletedWithAsyncCallback(cb__); } try { result__.prepare(__ice_id_name, OperationMode.Nonmutating, context__, explicitCtx__, synchronous__); result__.writeEmptyParams(); result__.invoke(); } catch(Ice.Exception ex__) { result__.abort(ex__); } return result__; } private void ice_id_completed__(AsyncResult r__, Callback_Object_ice_id cb__, Ice.ExceptionCallback excb__) { string ret__; try { ret__ = end_ice_id(r__); } catch(Ice.Exception ex__) { if(excb__ != null) { excb__(ex__); } return; } if(cb__ != null) { cb__(ret__); } } /// /// Invokes an operation dynamically. /// /// The name of the operation to invoke. /// The operation mode (normal or idempotent). /// The encoded in-parameters for the operation. /// The encoded out-paramaters and return value /// for the operation. The return value follows any out-parameters. /// If the operation completed successfully, the return value /// is true. If the operation raises a user exception, /// the return value is false; in this case, outEncaps /// contains the encoded user exception. If the operation raises a run-time exception, /// it throws it directly. public bool ice_invoke(string operation, OperationMode mode, byte[] inEncaps, out byte[] outEncaps) { return ice_invoke(operation, mode, inEncaps, out outEncaps, null, false); } /// /// Invokes an operation dynamically. /// /// The name of the operation to invoke. /// The operation mode (normal or idempotent). /// The encoded in-parameters for the operation. /// The encoded out-paramaters and return value /// for the operation. The return value follows any out-parameters. /// The context dictionary for the invocation. /// If the operation completed successfully, the return value /// is true. If the operation raises a user exception, /// the return value is false; in this case, outEncaps /// contains the encoded user exception. If the operation raises a run-time exception, /// it throws it directly. public bool ice_invoke(string operation, OperationMode mode, byte[] inEncaps, out byte[] outEncaps, Dictionary context) { return ice_invoke(operation, mode, inEncaps, out outEncaps, context, true); } private bool ice_invoke(string operation, OperationMode mode, byte[] inEncaps, out byte[] outEncaps, Dictionary context, bool explicitCtx) { return end_ice_invoke(out outEncaps, begin_ice_invoke(operation, mode, inEncaps, context, explicitCtx, true, null, null)); } public AsyncResult begin_ice_invoke(string operation, OperationMode mode, byte[] inEncaps) { return begin_ice_invoke(operation, mode, inEncaps, null, false, false, null, null); } public AsyncResult begin_ice_invoke(string operation, OperationMode mode, byte[] inEncaps, Dictionary context__) { return begin_ice_invoke(operation, mode, inEncaps, context__, true, false, null, null); } public AsyncResult begin_ice_invoke(string operation, OperationMode mode, byte[] inEncaps, AsyncCallback cb__, object cookie__) { return begin_ice_invoke(operation, mode, inEncaps, null, false, false, cb__, cookie__); } public AsyncResult begin_ice_invoke(string operation, OperationMode mode, byte[] inEncaps, Dictionary context__, AsyncCallback cb__, object cookie__) { return begin_ice_invoke(operation, mode, inEncaps, null, false, false, cb__, cookie__); } internal const string __ice_invoke_name = "ice_invoke"; public bool end_ice_invoke(out byte[] outEncaps, AsyncResult r__) { IceInternal.OutgoingAsync outAsync__ = IceInternal.OutgoingAsync.check(r__, this, __ice_invoke_name); try { bool ok = outAsync__.wait(); if(_reference.getMode() == IceInternal.Reference.Mode.ModeTwoway) { outEncaps = outAsync__.readParamEncaps(); } else { outEncaps = null; // Satisfy compiler } return ok; } finally { if(outAsync__ != null) { outAsync__.cacheMessageBuffers(); } } } private AsyncResult begin_ice_invoke(string operation, OperationMode mode, byte[] inEncaps, Dictionary context__, bool explicitCtx__, bool synchronous__, Ice.AsyncCallback cb__, object cookie__) { IceInternal.TwowayOutgoingAsync result__ = getTwowayOutgoingAsync(__ice_invoke_name, ice_invoke_completed__, cookie__); if(cb__ != null) { result__.whenCompletedWithAsyncCallback(cb__); } try { result__.prepare(operation, mode, context__, explicitCtx__, synchronous__); result__.writeParamEncaps(inEncaps); result__.invoke(); } catch(Ice.Exception ex__) { result__.abort(ex__); } return result__; } private void ice_invoke_completed__(AsyncResult r__, Callback_Object_ice_invoke cb__, Ice.ExceptionCallback excb__) { byte[] outEncaps; bool ret__; try { ret__ = end_ice_invoke(out outEncaps, r__); } catch(Ice.Exception ex__) { if(excb__ != null) { excb__(ex__); } return; } if(cb__ != null) { cb__(ret__, outEncaps); } } /// /// Returns the identity embedded in this proxy. /// The identity of the target object. /// public Identity ice_getIdentity() { return (Identity)_reference.getIdentity().Clone(); } /// /// Creates a new proxy that is identical to this proxy, except for the per-proxy context. /// The identity for the new proxy. /// The proxy with the new identity. /// public ObjectPrx ice_identity(Identity newIdentity) { if(newIdentity.name.Length == 0) { throw new IllegalIdentityException(); } if(newIdentity.Equals(_reference.getIdentity())) { return this; } else { ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); proxy.setup(_reference.changeIdentity(newIdentity)); return proxy; } } /// /// Returns the per-proxy context for this proxy. /// /// The per-proxy context. If the proxy does not have a per-proxy (implicit) context, the return value /// is null. public Dictionary ice_getContext() { return new Dictionary(_reference.getContext()); } /// /// Creates a new proxy that is identical to this proxy, except for the per-proxy context. /// /// The context for the new proxy. /// The proxy with the new per-proxy context. public ObjectPrx ice_context(Dictionary newContext) { return newInstance(_reference.changeContext(newContext)); } /// /// Returns the facet for this proxy. /// /// The facet for this proxy. If the proxy uses the default facet, the return value is the /// empty string. public string ice_getFacet() { return _reference.getFacet(); } /// /// Creates a new proxy that is identical to this proxy, except for the facet. /// /// The facet for the new proxy. /// The proxy with the new facet. public ObjectPrx ice_facet(string newFacet) { if(newFacet == null) { newFacet = ""; } if(newFacet.Equals(_reference.getFacet())) { return this; } else { ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); proxy.setup(_reference.changeFacet(newFacet)); return proxy; } } /// /// Returns the adapter ID for this proxy. /// /// The adapter ID. If the proxy does not have an adapter ID, the return value is the /// empty string. public string ice_getAdapterId() { return _reference.getAdapterId(); } /// /// Creates a new proxy that is identical to this proxy, except for the adapter ID. /// /// The adapter ID for the new proxy. /// The proxy with the new adapter ID. public ObjectPrx ice_adapterId(string newAdapterId) { if(newAdapterId == null) { newAdapterId = ""; } if(newAdapterId.Equals(_reference.getAdapterId())) { return this; } else { return newInstance(_reference.changeAdapterId(newAdapterId)); } } /// /// Returns the endpoints used by this proxy. /// /// The endpoints used by this proxy. public Endpoint[] ice_getEndpoints() { return (Endpoint[])_reference.getEndpoints().Clone(); } /// /// Creates a new proxy that is identical to this proxy, except for the endpoints. /// /// The endpoints for the new proxy. /// The proxy with the new endpoints. public ObjectPrx ice_endpoints(Endpoint[] newEndpoints) { if(Arrays.Equals(newEndpoints, _reference.getEndpoints())) { return this; } else { IceInternal.EndpointI[] endpts = new IceInternal.EndpointI[newEndpoints.Length]; for(int i = 0; i < newEndpoints.Length; ++i) { endpts[i] = (IceInternal.EndpointI)newEndpoints[i]; } return newInstance(_reference.changeEndpoints(endpts)); } } /// /// Returns the locator cache timeout of this proxy. /// /// The locator cache timeout value (in seconds). public int ice_getLocatorCacheTimeout() { return _reference.getLocatorCacheTimeout(); } /// /// Creates a new proxy that is identical to this proxy, except for the locator cache timeout. /// /// The new locator cache timeout (in seconds). public ObjectPrx ice_locatorCacheTimeout(int newTimeout) { if(newTimeout < -1) { throw new System.ArgumentException("invalid value passed to ice_locatorCacheTimeout: " + newTimeout); } if(newTimeout == _reference.getLocatorCacheTimeout()) { return this; } else { return newInstance(_reference.changeLocatorCacheTimeout(newTimeout)); } } /// /// Returns the invocation timeout of this proxy. /// /// The invocation timeout value (in seconds). public int ice_getInvocationTimeout() { return _reference.getInvocationTimeout(); } /// /// Creates a new proxy that is identical to this proxy, except for the invocation timeout. /// /// The new invocation timeout (in seconds). public ObjectPrx ice_invocationTimeout(int newTimeout) { if(newTimeout < 1 && newTimeout != -1 && newTimeout != -2) { throw new System.ArgumentException("invalid value passed to ice_invocationTimeout: " + newTimeout); } if(newTimeout == _reference.getInvocationTimeout()) { return this; } else { return newInstance(_reference.changeInvocationTimeout(newTimeout)); } } /// /// Returns whether this proxy caches connections. /// /// True if this proxy caches connections; false, otherwise. public bool ice_isConnectionCached() { return _reference.getCacheConnection(); } /// /// Creates a new proxy that is identical to this proxy, except for connection caching. /// /// True if the new proxy should cache connections; false, otherwise. /// The new proxy with the specified caching policy. public ObjectPrx ice_connectionCached(bool newCache) { if(newCache == _reference.getCacheConnection()) { return this; } else { return newInstance(_reference.changeCacheConnection(newCache)); } } /// /// Returns how this proxy selects endpoints (randomly or ordered). /// /// The endpoint selection policy. public EndpointSelectionType ice_getEndpointSelection() { return _reference.getEndpointSelection(); } /// /// Creates a new proxy that is identical to this proxy, except for the endpoint selection policy. /// /// The new endpoint selection policy. /// The new proxy with the specified endpoint selection policy. public ObjectPrx ice_endpointSelection(EndpointSelectionType newType) { if(newType == _reference.getEndpointSelection()) { return this; } else { return newInstance(_reference.changeEndpointSelection(newType)); } } /// /// Returns whether this proxy communicates only via secure endpoints. /// /// True if this proxy communicates only vi secure endpoints; false, otherwise. public bool ice_isSecure() { return _reference.getSecure(); } /// /// Creates a new proxy that is identical to this proxy, except for how it selects endpoints. /// /// If b is true, only endpoints that use a secure transport are /// used by the new proxy. If b is false, the returned proxy uses both secure and insecure /// endpoints. /// The new proxy with the specified selection policy. public ObjectPrx ice_secure(bool b) { if(b == _reference.getSecure()) { return this; } else { return newInstance(_reference.changeSecure(b)); } } /// /// Creates a new proxy that is identical to this proxy, except for the encoding used to marshal /// parameters. /// /// The encoding version to use to marshal requests parameters. /// The new proxy with the specified encoding version. public ObjectPrx ice_encodingVersion(Ice.EncodingVersion e) { if(e.Equals(_reference.getEncoding())) { return this; } else { return newInstance(_reference.changeEncoding(e)); } } /// Returns the encoding version used to marshal requests parameters. /// The encoding version. public Ice.EncodingVersion ice_getEncodingVersion() { return _reference.getEncoding(); } /// /// Returns whether this proxy prefers secure endpoints. /// /// True if the proxy always attempts to invoke via secure endpoints before it /// attempts to use insecure endpoints; false, otherwise. public bool ice_isPreferSecure() { return _reference.getPreferSecure(); } /// /// Creates a new proxy that is identical to this proxy, except for its endpoint selection policy. /// /// If b is true, the new proxy will use secure endpoints for invocations /// and only use insecure endpoints if an invocation cannot be made via secure endpoints. If b is /// false, the proxy prefers insecure endpoints to secure ones. /// The new proxy with the new endpoint selection policy. public ObjectPrx ice_preferSecure(bool b) { if(b == _reference.getPreferSecure()) { return this; } else { return newInstance(_reference.changePreferSecure(b)); } } /// /// Returns the router for this proxy. /// /// The router for the proxy. If no router is configured for the proxy, the return value /// is null. public Ice.RouterPrx ice_getRouter() { IceInternal.RouterInfo ri = _reference.getRouterInfo(); return ri != null ? ri.getRouter() : null; } /// /// Creates a new proxy that is identical to this proxy, except for the router. /// /// The router for the new proxy. /// The new proxy with the specified router. public ObjectPrx ice_router(RouterPrx router) { IceInternal.Reference @ref = _reference.changeRouter(router); if(@ref.Equals(_reference)) { return this; } else { return newInstance(@ref); } } /// /// Returns the locator for this proxy. /// /// The locator for this proxy. If no locator is configured, the return value is null. public Ice.LocatorPrx ice_getLocator() { IceInternal.LocatorInfo li = _reference.getLocatorInfo(); return li != null ? li.getLocator() : null; } /// /// Creates a new proxy that is identical to this proxy, except for the locator. /// /// The locator for the new proxy. /// The new proxy with the specified locator. public ObjectPrx ice_locator(LocatorPrx locator) { IceInternal.Reference @ref = _reference.changeLocator(locator); if(@ref.Equals(_reference)) { return this; } else { return newInstance(@ref); } } /// /// Returns whether this proxy uses collocation optimization. /// /// True if the proxy uses collocation optimization; false, otherwise. public bool ice_isCollocationOptimized() { return _reference.getCollocationOptimized(); } /// /// Creates a new proxy that is identical to this proxy, except for collocation optimization. /// /// True if the new proxy enables collocation optimization; false, otherwise. /// The new proxy the specified collocation optimization. public ObjectPrx ice_collocationOptimized(bool b) { if(b == _reference.getCollocationOptimized()) { return this; } else { return newInstance(_reference.changeCollocationOptimized(b)); } } /// /// Creates a new proxy that is identical to this proxy, but uses twoway invocations. /// /// A new proxy that uses twoway invocations. public ObjectPrx ice_twoway() { if(_reference.getMode() == IceInternal.Reference.Mode.ModeTwoway) { return this; } else { return newInstance(_reference.changeMode(IceInternal.Reference.Mode.ModeTwoway)); } } /// /// Returns whether this proxy uses twoway invocations. /// /// True if this proxy uses twoway invocations; false, otherwise. public bool ice_isTwoway() { return _reference.getMode() == IceInternal.Reference.Mode.ModeTwoway; } /// /// Creates a new proxy that is identical to this proxy, but uses oneway invocations. /// /// A new proxy that uses oneway invocations. public ObjectPrx ice_oneway() { if(_reference.getMode() == IceInternal.Reference.Mode.ModeOneway) { return this; } else { return newInstance(_reference.changeMode(IceInternal.Reference.Mode.ModeOneway)); } } /// /// Returns whether this proxy uses oneway invocations. /// /// True if this proxy uses oneway invocations; false, otherwise. public bool ice_isOneway() { return _reference.getMode() == IceInternal.Reference.Mode.ModeOneway; } /// /// Creates a new proxy that is identical to this proxy, but uses batch oneway invocations. /// /// A new proxy that uses batch oneway invocations. public ObjectPrx ice_batchOneway() { if(_reference.getMode() == IceInternal.Reference.Mode.ModeBatchOneway) { return this; } else { return newInstance(_reference.changeMode(IceInternal.Reference.Mode.ModeBatchOneway)); } } /// /// Returns whether this proxy uses batch oneway invocations. /// /// True if this proxy uses batch oneway invocations; false, otherwise. public bool ice_isBatchOneway() { return _reference.getMode() == IceInternal.Reference.Mode.ModeBatchOneway; } /// /// Creates a new proxy that is identical to this proxy, but uses datagram invocations. /// /// A new proxy that uses datagram invocations. public ObjectPrx ice_datagram() { if(_reference.getMode() == IceInternal.Reference.Mode.ModeDatagram) { return this; } else { return newInstance(_reference.changeMode(IceInternal.Reference.Mode.ModeDatagram)); } } /// /// Returns whether this proxy uses datagram invocations. /// /// True if this proxy uses datagram invocations; false, otherwise. public bool ice_isDatagram() { return _reference.getMode() == IceInternal.Reference.Mode.ModeDatagram; } /// /// Creates a new proxy that is identical to this proxy, but uses batch datagram invocations. /// /// A new proxy that uses batch datagram invocations. public ObjectPrx ice_batchDatagram() { if(_reference.getMode() == IceInternal.Reference.Mode.ModeBatchDatagram) { return this; } else { return newInstance(_reference.changeMode(IceInternal.Reference.Mode.ModeBatchDatagram)); } } /// /// Returns whether this proxy uses batch datagram invocations. /// /// True if this proxy uses batch datagram invocations; false, otherwise. public bool ice_isBatchDatagram() { return _reference.getMode() == IceInternal.Reference.Mode.ModeBatchDatagram; } /// /// Creates a new proxy that is identical to this proxy, except for compression. /// /// True enables compression for the new proxy; false disables compression. /// A new proxy with the specified compression setting. public ObjectPrx ice_compress(bool co) { IceInternal.Reference @ref = _reference.changeCompress(co); if(@ref.Equals(_reference)) { return this; } else { return newInstance(@ref); } } /// /// Creates a new proxy that is identical to this proxy, except for its timeout setting. /// /// The timeout for the new proxy in milliseconds. /// A new proxy with the specified timeout. public ObjectPrx ice_timeout(int t) { if(t < 1 && t != -1) { throw new System.ArgumentException("invalid value passed to ice_timeout: " + t); } IceInternal.Reference @ref = _reference.changeTimeout(t); if(@ref.Equals(_reference)) { return this; } else { return newInstance(@ref); } } /// /// Creates a new proxy that is identical to this proxy, except for its connection ID. /// /// The connection ID for the new proxy. An empty string removes the /// connection ID. /// A new proxy with the specified connection ID. public ObjectPrx ice_connectionId(string connectionId) { IceInternal.Reference @ref = _reference.changeConnectionId(connectionId); if(@ref.Equals(_reference)) { return this; } else { return newInstance(@ref); } } /// /// Returns the connection id of this proxy. /// /// The connection id. public string ice_getConnectionId() { return _reference.getConnectionId(); } /// /// Returns the Connection for this proxy. If the proxy does not yet have an established connection, /// it first attempts to create a connection. /// /// The Connection for this proxy. /// If the proxy uses collocation optimization and denotes a /// collocated object. public Connection ice_getConnection() { return end_ice_getConnection(begin_ice_getConnection()); } public AsyncResult begin_ice_getConnection() { return begin_ice_getConnectionInternal(null, null); } internal const string __ice_getConnection_name = "ice_getConnection"; public AsyncResult begin_ice_getConnection(Ice.AsyncCallback cb, object cookie) { return begin_ice_getConnectionInternal(cb, cookie); } public Connection end_ice_getConnection(Ice.AsyncResult r) { IceInternal.ProxyGetConnection outAsync = IceInternal.ProxyGetConnection.check(r, this, __ice_getConnection_name); outAsync.wait(); return ice_getCachedConnection(); } private AsyncResult begin_ice_getConnectionInternal(Ice.AsyncCallback cb, object cookie) { IceInternal.ProxyGetConnection result = new IceInternal.ProxyGetConnection(this, __ice_getConnection_name, ice_getConnection_completed__, cookie); if(cb != null) { result.whenCompletedWithAsyncCallback(cb); } try { result.invoke(); } catch(Ice.Exception ex) { result.abort(ex); } return result; } private void ice_getConnection_completed__(AsyncResult r, Callback_Object_ice_getConnection cb, Ice.ExceptionCallback excb) { Connection ret; try { ret = end_ice_getConnection(r); } catch(Ice.Exception ex) { if(excb != null) { excb(ex); } return; } if(cb != null) { cb(ret); } } /// /// Returns the cached Connection for this proxy. If the proxy does not yet have an established /// connection, it does not attempt to create a connection. /// /// The cached Connection for this proxy (null if the proxy does not have /// an established connection). /// If the proxy uses collocation optimization and denotes a /// collocated object. public Connection ice_getCachedConnection() { IceInternal.RequestHandler handler; lock(this) { handler = _requestHandler; } if(handler != null) { try { return handler.getConnection(); } catch(LocalException) { } } return null; } /// /// Flushes any pending batched requests for this communicator. The call blocks until the flush is complete. /// public void ice_flushBatchRequests() { end_ice_flushBatchRequests(begin_ice_flushBatchRequests()); } internal const string __ice_flushBatchRequests_name = "ice_flushBatchRequests"; public AsyncResult begin_ice_flushBatchRequests() { return begin_ice_flushBatchRequests(null, null); } public AsyncResult begin_ice_flushBatchRequests(Ice.AsyncCallback cb, object cookie) { IceInternal.ProxyFlushBatch result = new IceInternal.ProxyFlushBatch(this, __ice_flushBatchRequests_name, cookie); if(cb != null) { result.whenCompletedWithAsyncCallback(cb); } try { result.invoke(); } catch(Ice.Exception ex) { result.abort(ex); } return result; } public void end_ice_flushBatchRequests(Ice.AsyncResult r) { IceInternal.ProxyFlushBatch outAsync = IceInternal.ProxyFlushBatch.check(r, this, __ice_flushBatchRequests_name); outAsync.wait(); } /// /// Returns whether this proxy equals the passed object. Two proxies are equal if they are equal in all /// respects, that is, if their object identity, endpoints timeout settings, and so on are all equal. /// /// The object to compare this proxy with. /// True if this proxy is equal to r; false, otherwise. public override bool Equals(object r) { ObjectPrxHelperBase rhs = r as ObjectPrxHelperBase; return object.ReferenceEquals(rhs, null) ? false : _reference.Equals(rhs._reference); } /// /// Returns whether two proxies are equal. Two proxies are equal if they are equal in all /// respects, that is, if their object identity, endpoints timeout settings, and so on are all equal. /// /// A proxy to compare with the proxy rhs. /// A proxy to compare with the proxy lhs. /// True if the proxies are equal; false, otherwise. public static bool Equals(ObjectPrxHelperBase lhs, ObjectPrxHelperBase rhs) { return object.ReferenceEquals(lhs, null) ? object.ReferenceEquals(rhs, null) : lhs.Equals(rhs); } /// /// Returns whether two proxies are equal. Two proxies are equal if they are equal in all /// respects, that is, if their object identity, endpoints timeout settings, and so on are all equal. /// /// A proxy to compare with the proxy rhs. /// A proxy to compare with the proxy lhs. /// True if the proxies are equal; false, otherwise. public static bool operator==(ObjectPrxHelperBase lhs, ObjectPrxHelperBase rhs) { return Equals(lhs, rhs); } /// /// Returns whether two proxies are not equal. Two proxies are equal if they are equal in all /// respects, that is, if their object identity, endpoints timeout settings, and so on are all equal. /// /// A proxy to compare with the proxy rhs. /// A proxy to compare with the proxy lhs. /// True if the proxies are not equal; false, otherwise. public static bool operator!=(ObjectPrxHelperBase lhs, ObjectPrxHelperBase rhs) { return !Equals(lhs, rhs); } public IceInternal.Reference reference__() { return _reference; } public void copyFrom__(ObjectPrx from) { lock(from) { ObjectPrxHelperBase h = (ObjectPrxHelperBase)from; _reference = h._reference; _requestHandler = h._requestHandler; } } public int handleException__(Exception ex, IceInternal.RequestHandler handler, OperationMode mode, bool sent, ref int cnt) { updateRequestHandler__(handler, null); // Clear the request handler // // We only retry local exception, system exceptions aren't retried. // // A CloseConnectionException indicates graceful server shutdown, and is therefore // always repeatable without violating "at-most-once". That's because by sending a // close connection message, the server guarantees that all outstanding requests // can safely be repeated. // // An ObjectNotExistException can always be retried as well without violating // "at-most-once" (see the implementation of the checkRetryAfterException method // of the ProxyFactory class for the reasons why it can be useful). // // If the request didn't get sent or if it's non-mutating or idempotent it can // also always be retried if the retry count isn't reached. // if(ex is LocalException && (!sent || mode == OperationMode.Nonmutating || mode == OperationMode.Idempotent || ex is CloseConnectionException || ex is ObjectNotExistException)) { try { return _reference.getInstance().proxyFactory().checkRetryAfterException((LocalException)ex, _reference, ref cnt); } catch(CommunicatorDestroyedException) { // // The communicator is already destroyed, so we cannot retry. // throw ex; } } else { throw ex; // Retry could break at-most-once semantics, don't retry. } } public void checkTwowayOnly__(string name) { // // No mutex lock necessary, there is nothing mutable in this // operation. // if(!ice_isTwoway()) { TwowayOnlyException ex = new TwowayOnlyException(); ex.operation = name; throw ex; } } public void checkAsyncTwowayOnly__(string name) { // // No mutex lock necessary, there is nothing mutable in this // operation. // if(!ice_isTwoway()) { throw new System.ArgumentException("`" + name + "' can only be called with a twoway proxy"); } } public void end__(AsyncResult r, string operation) { IceInternal.ProxyOutgoingAsyncBase result = IceInternal.ProxyOutgoingAsyncBase.check(r, this, operation); try { bool ok = result.wait(); if(_reference.getMode() == IceInternal.Reference.Mode.ModeTwoway) { IceInternal.OutgoingAsync outAsync = (IceInternal.OutgoingAsync)result; if(!ok) { try { outAsync.throwUserException(); } catch(Ice.UserException ex) { throw new Ice.UnknownUserException(ex.ice_name(), ex); } } outAsync.readEmptyParams(); } } finally { if(result != null) { result.cacheMessageBuffers(); } } } public IceInternal.RequestHandler getRequestHandler__() { if(_reference.getCacheConnection()) { lock(this) { if(_requestHandler != null) { return _requestHandler; } } } return _reference.getRequestHandler(this); } public IceInternal.BatchRequestQueue getBatchRequestQueue__() { lock(this) { if(_batchRequestQueue == null) { _batchRequestQueue = _reference.getBatchRequestQueue(); } return _batchRequestQueue; } } public IceInternal.RequestHandler setRequestHandler__(IceInternal.RequestHandler handler) { if(_reference.getCacheConnection()) { lock(this) { if(_requestHandler == null) { _requestHandler = handler; } return _requestHandler; } } return handler; } public void updateRequestHandler__(IceInternal.RequestHandler previous, IceInternal.RequestHandler handler) { if(_reference.getCacheConnection() && previous != null) { lock(this) { if(_requestHandler != null && _requestHandler != handler) { // // Update the request handler only if "previous" is the same // as the current request handler. This is called after // connection binding by the connect request handler. We only // replace the request handler if the current handler is the // connect request handler. // _requestHandler = _requestHandler.update(previous, handler); } } } } // // Only for use by IceInternal.ProxyFactory // public void setup(IceInternal.Reference @ref) { // // No need to synchronize, as this operation is only called // upon initial initialization. // Debug.Assert(_reference == null); Debug.Assert(_requestHandler == null); _reference = @ref; } private ObjectPrxHelperBase newInstance(IceInternal.Reference @ref) { ObjectPrxHelperBase proxy = (ObjectPrxHelperBase)Activator.CreateInstance(GetType()); proxy.setup(@ref); return proxy; } private IceInternal.Reference _reference; private IceInternal.RequestHandler _requestHandler; private IceInternal.BatchRequestQueue _batchRequestQueue; private struct StreamCacheEntry { public IceInternal.BasicStream iss; public IceInternal.BasicStream os; } private LinkedList _streamCache; } /// /// Base class for all proxy helpers. /// public class ObjectPrxHelper : ObjectPrxHelperBase { /// /// Casts a proxy to {@link ObjectPrx}. This call contacts /// the server and will throw an Ice run-time exception if the target /// object does not exist or the server cannot be reached. /// /// The proxy to cast to ObjectPrx. /// b. public static ObjectPrx checkedCast(ObjectPrx b) { return b; } /// /// Casts a proxy to {@link ObjectPrx}. This call contacts /// the server and throws an Ice run-time exception if the target /// object does not exist or the server cannot be reached. /// /// The proxy to cast to ObjectPrx. /// The Context map for the invocation. /// b. public static ObjectPrx checkedCast(ObjectPrx b, Dictionary ctx) { return b; } /// /// Creates a new proxy that is identical to the passed proxy, except /// for its facet. This call contacts /// the server and throws an Ice run-time exception if the target /// object does not exist, the specified facet does not exist, or the server cannot be reached. /// /// The proxy to cast to ObjectPrx. /// The facet for the new proxy. /// The new proxy with the specified facet. public static ObjectPrx checkedCast(ObjectPrx b, string f) { ObjectPrx d = null; if(b != null) { try { ObjectPrx bb = b.ice_facet(f); bool ok = bb.ice_isA("::Ice::Object"); Debug.Assert(ok); ObjectPrxHelper h = new ObjectPrxHelper(); h.copyFrom__(bb); d = h; } catch(Ice.FacetNotExistException) { } } return d; } /// /// Creates a new proxy that is identical to the passed proxy, except /// for its facet. This call contacts /// the server and throws an Ice run-time exception if the target /// object does not exist, the specified facet does not exist, or the server cannot be reached. /// /// The proxy to cast to ObjectPrx. /// The facet for the new proxy. /// The Context map for the invocation. /// The new proxy with the specified facet. public static ObjectPrx checkedCast(ObjectPrx b, string f, Dictionary ctx) { ObjectPrx d = null; if(b != null) { try { ObjectPrx bb = b.ice_facet(f); bool ok = bb.ice_isA("::Ice::Object", ctx); Debug.Assert(ok); ObjectPrxHelper h = new ObjectPrxHelper(); h.copyFrom__(bb); d = h; } catch(Ice.FacetNotExistException) { } } return d; } /// /// Casts a proxy to {@link ObjectPrx}. This call does /// not contact the server and always succeeds. /// /// The proxy to cast to ObjectPrx. /// b. public static ObjectPrx uncheckedCast(ObjectPrx b) { return b; } /// /// Creates a new proxy that is identical to the passed proxy, except /// for its facet. This call does not contact the server and always succeeds. /// /// The proxy to cast to ObjectPrx. /// The facet for the new proxy. /// The new proxy with the specified facet. public static ObjectPrx uncheckedCast(ObjectPrx b, string f) { ObjectPrx d = null; if(b != null) { ObjectPrx bb = b.ice_facet(f); ObjectPrxHelper h = new ObjectPrxHelper(); h.copyFrom__(bb); d = h; } return d; } /// /// Returns the Slice type id of the interface or class associated /// with this proxy class. /// /// The type id, "::Ice::Object". public static string ice_staticId() { return Ice.ObjectImpl.ice_staticId(); } } }