예제 #1
0
		/// <summary>
		/// Invoke a method on a given connection and handle result.
		/// </summary>
		/// <param name="connection">Connection to invoke method on.</param>
		/// <param name="method">Name of the method to invoke.</param>
		/// <param name="args">Parameters to pass to the method.</param>
		/// <param name="callback">Object to notify when result is received.</param>
		/// <returns><code>true</code> if the connection supports method calls, otherwise <code>false</code></returns>
		public static bool InvokeOnConnection(IConnection connection, string method, object[] args, IPendingServiceCallback callback) {
			if (connection is IServiceCapableConnection) {
				if (callback == null)
					(connection as IServiceCapableConnection).Invoke(method, args);
				else
					(connection as IServiceCapableConnection).Invoke(method, args, callback);
				return true;
			} else
				return false;
		}
예제 #2
0
 /// <summary>
 /// Invoke a method on a given connection and handle result.
 /// </summary>
 /// <param name="connection">Connection to invoke method on.</param>
 /// <param name="method">Name of the method to invoke.</param>
 /// <param name="args">Parameters to pass to the method.</param>
 /// <param name="callback">Object to notify when result is received.</param>
 /// <returns><code>true</code> if the connection supports method calls, otherwise <code>false</code></returns>
 public static bool InvokeOnConnection(IConnection connection, string method, object[] args, IPendingServiceCallback callback)
 {
     if (connection is IServiceCapableConnection)
     {
         if (callback == null)
         {
             (connection as IServiceCapableConnection).Invoke(method, args);
         }
         else
         {
             (connection as IServiceCapableConnection).Invoke(method, args, callback);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #3
0
		/// <summary>
		/// Begins an asynchronous operation to invoke a service by name with parameters and callback.
		/// </summary>
		/// <param name="asyncCallback">The AsyncCallback delegate.</param>
		/// <param name="method">Method name.</param>
		/// <param name="parameters">Invocation parameters passed to the method.</param>
		/// <param name="callback">Callback used to handle return values.</param>
		/// <returns>An IAsyncResult that references the asynchronous invocation.</returns>
		/// <remarks>
		/// <para>
		/// You can create a callback method that implements the AsyncCallback delegate and pass its name to the BeginInvoke method.
		/// </para>
		/// <para>
		/// Your callback method should invoke the EndInvoke method. When your application calls BeginInvoke, the system will use a separate thread to execute the specified callback method, and will block on EndInvoke until the client is invoked successfully or throws an exception.
		/// </para>
		/// </remarks>
		public IAsyncResult BeginInvoke(AsyncCallback asyncCallback, string method, object[] parameters, IPendingServiceCallback callback) {
			IPendingServiceCall call = new PendingCall(method, parameters);
			if (callback != null)
				call.RegisterCallback(callback);
			return BeginInvoke(asyncCallback, call);
		}
예제 #4
0
		/// <summary>
		/// Invoke method with parameters and callback.
		/// </summary>
		/// <param name="method">Method name.</param>
		/// <param name="parameters">Invocation parameters passed to the method.</param>
		/// <param name="callback">Callback used to handle return values.</param>
		public void Invoke(string method, object[] parameters, IPendingServiceCallback callback) {
			IPendingServiceCall call = new PendingCall(method, parameters);
			if (callback != null)
				call.RegisterCallback(callback);
			Invoke(call);
		}
예제 #5
0
		public InvokeData(FluorineContext context, string method, object[] arguments, IPendingServiceCallback callback, bool ignoreSelf, IScope targetScope) {
			_context = context;
			_method = method;
			_arguments = arguments;
			_callback = callback;
			_ignoreSelf = ignoreSelf;
			_targetScope = targetScope;
		}
예제 #6
0
 /// <summary>
 /// Begins an asynchronous operation to invoke clients with parameters and callback.
 /// </summary>
 /// <param name="asyncCallback">The AsyncCallback delegate.</param>
 /// <param name="method">Method name.</param>
 /// <param name="arguments">Invocation parameters passed to the method.</param>
 /// <param name="callback">Callback used to handle return values.</param>
 /// <param name="ignoreSelf">Current client shoud be ignored.</param>
 /// <param name="targetScope">Invoke clients subscribed to the specified Scope.</param>
 /// <returns>An IAsyncResult that references the asynchronous invocation.</returns>
 /// <remarks>
 /// <para>
 /// The <i>asyncCallback</i> delegate identifies the callback invoked when the messages are sent, the <i>callback</i> object identifies the callback handling client responses.
 /// </para>
 /// <para>
 /// You can create a callback method that implements the AsyncCallback delegate and pass its name to the BeginInvokeClients method.
 /// </para>
 /// <para>
 /// Your callback method should invoke the EndInvokeClients method. When your application calls BeginInvokeClients, the system will use a separate thread to execute the specified callback method, and will block on EndInvokeClients until the clients are invoked successfully or throws an exception.
 /// </para>
 /// </remarks>
 protected IAsyncResult BeginInvokeClients(AsyncCallback asyncCallback, string method, object[] arguments, IPendingServiceCallback callback, bool ignoreSelf, IScope targetScope)
 {
     // Create IAsyncResult object identifying the asynchronous operation
     AsyncResultNoResult ar = new AsyncResultNoResult(asyncCallback, new InvokeData(FluorineContext.Current, method, arguments, callback, ignoreSelf, targetScope));
     // Use a thread pool thread to perform the operation
     FluorineFx.Threading.ThreadPoolEx.Global.QueueUserWorkItem(new System.Threading.WaitCallback(OnBeginInvokeClients), ar);
     // Return the IAsyncResult to the caller
     return ar;
 }
예제 #7
0
 /// <summary>
 /// Begins an asynchronous operation to invoke clients with parameters and callback.
 /// </summary>
 /// <param name="asyncCallback">The AsyncCallback delegate.</param>
 /// <param name="method">Method name.</param>
 /// <param name="arguments">Invocation parameters passed to the method.</param>
 /// <param name="callback">Callback used to handle return values.</param>
 /// <returns>An IAsyncResult that references the asynchronous invocation.</returns>
 /// <remarks>
 /// <para>
 /// The <i>asyncCallback</i> delegate identifies the callback invoked when the messages are sent, the <i>callback</i> object identifies the callback handling client responses.
 /// </para>
 /// <para>
 /// You can create a callback method that implements the AsyncCallback delegate and pass its name to the BeginInvokeClients method.
 /// </para>
 /// <para>
 /// Your callback method should invoke the EndInvokeClients method. When your application calls BeginInvokeClients, the system will use a separate thread to execute the specified callback method, and will block on EndInvokeClients until the clients are invoked successfully or throws an exception.
 /// </para>
 /// </remarks>
 protected IAsyncResult BeginInvokeClients(AsyncCallback asyncCallback, string method, object[] arguments, IPendingServiceCallback callback)
 {
     return BeginInvokeClients(asyncCallback, method, arguments, callback, false);
 }
예제 #8
0
 /// <summary>
 /// Invoke clients with parameters and callback.
 /// </summary>
 /// <param name="method">Method name.</param>
 /// <param name="arguments">Invocation parameters passed to the method.</param>
 /// <param name="callback">Callback used to handle return values.</param>
 /// <param name="ignoreSelf">Current client shoud be ignored.</param>
 protected void InvokeClients(string method, object[] arguments, IPendingServiceCallback callback, bool ignoreSelf)
 {
     InvokeClients(method, arguments, callback, ignoreSelf, this.Scope);
 }
예제 #9
0
 public void Invoke(string method, IPendingServiceCallback callback)
 {
     this.Invoke(method, null, callback);
 }
예제 #10
0
 public AmfRequestData(HttpWebRequest request, AMFMessage amfMessage, PendingCall call, IPendingServiceCallback callback, object responder)
 {
     _call       = call;
     _responder  = responder;
     _request    = request;
     _amfMessage = amfMessage;
     _callback   = callback;
 }
예제 #11
0
        public void Call(string endpoint, string destination, string source, string operation, IPendingServiceCallback callback, params object[] arguments)
        {
            if (_netConnection.ObjectEncoding == ObjectEncoding.AMF0)
            {
                throw new NotSupportedException("AMF0 not supported for Flex RPC");
            }
            try
            {
                TypeHelper._Init();

                Uri            uri     = new Uri(_gatewayUrl);
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
                request.ContentType = ContentType.AMF;
                request.Method      = "POST";
#if !(SILVERLIGHT)
                request.CookieContainer = _netConnection.CookieContainer;
#endif
                AMFMessage amfMessage = new AMFMessage((ushort)_netConnection.ObjectEncoding);

                RemotingMessage remotingMessage = new RemotingMessage();
                remotingMessage.clientId    = Guid.NewGuid().ToString("D");
                remotingMessage.destination = destination;
                remotingMessage.messageId   = Guid.NewGuid().ToString("D");
                remotingMessage.timestamp   = 0;
                remotingMessage.timeToLive  = 0;
                remotingMessage.SetHeader(MessageBase.EndpointHeader, endpoint);
                remotingMessage.SetHeader(MessageBase.FlexClientIdHeader, _netConnection.ClientId ?? "nil");
                //Service stuff
                remotingMessage.source    = source;
                remotingMessage.operation = operation;
                remotingMessage.body      = arguments;

                foreach (KeyValuePair <string, AMFHeader> entry in _netConnection.Headers)
                {
                    amfMessage.AddHeader(entry.Value);
                }
                AMFBody amfBody = new AMFBody(null, null, new object[] { remotingMessage });
                amfMessage.AddBody(amfBody);

                PendingCall    call           = new PendingCall(source, operation, arguments);
                AmfRequestData amfRequestData = new AmfRequestData(request, amfMessage, call, callback, null);
                request.BeginGetRequestStream(BeginRequestFlexCall, amfRequestData);
            }
            catch (Exception ex)
            {
                _netConnection.RaiseNetStatus(ex);
            }
        }
예제 #12
0
 public void Invoke(string method, object[] parameters, IPendingServiceCallback callback)
 {
     _connection.Invoke(method, parameters, callback);
 }
예제 #13
0
 public void Invoke(string method, IPendingServiceCallback callback)
 {
     _connection.Invoke(method, callback);
 }
예제 #14
0
 public CallHandler(IPendingServiceCallback callback)
 {
     _callback = callback;
 }
예제 #15
0
        public void Call(string endpoint, string destination, string source, string operation, IPendingServiceCallback callback, params object[] arguments)
        {
            if (_netConnection.ObjectEncoding == ObjectEncoding.AMF0)
            {
                throw new NotSupportedException("AMF0 not supported for Flex RPC");
            }
            try
            {
                TypeHelper._Init();

                RemotingMessage remotingMessage = new RemotingMessage();
                remotingMessage.clientId    = Guid.NewGuid().ToString("D");
                remotingMessage.destination = destination;
                remotingMessage.messageId   = Guid.NewGuid().ToString("D");
                remotingMessage.timestamp   = 0;
                remotingMessage.timeToLive  = 0;
                remotingMessage.SetHeader(MessageBase.EndpointHeader, endpoint);
                remotingMessage.SetHeader(MessageBase.FlexClientIdHeader, _netConnection.ClientId ?? "nil");
                //Service stuff
                remotingMessage.source    = source;
                remotingMessage.operation = operation;
                remotingMessage.body      = arguments;

                FlexInvoke  invoke      = new FlexInvoke();
                PendingCall pendingCall = new PendingCall(null, new object[] { remotingMessage });
                if (callback != null)
                {
                    CallHandler handler = new CallHandler(callback);
                    pendingCall.RegisterCallback(handler);
                }
                invoke.ServiceCall = pendingCall;
                invoke.InvokeId    = _connection.InvokeId;
                _connection.RegisterPendingCall(invoke.InvokeId, pendingCall);
                Write(invoke);
            }
            catch (Exception ex)
            {
                _netConnection.RaiseNetStatus(ex);
            }
        }
예제 #16
0
 public void Call(string command, IPendingServiceCallback callback, params object[] arguments)
 {
     this._netConnectionClient.Call(command, callback, arguments);
 }
예제 #17
0
 /// <summary>
 /// Invoke clients with parameters and callback.
 /// </summary>
 /// <param name="method">Method name.</param>
 /// <param name="arguments">Invocation parameters passed to the method.</param>
 /// <param name="callback">Callback used to handle return values.</param>
 protected void InvokeClients(string method, object[] arguments, IPendingServiceCallback callback)
 {
     InvokeClients(method, arguments, callback, false);
 }
예제 #18
0
 public void Call(string endpoint, string destination, string source, string operation, IPendingServiceCallback callback, params object[] arguments)
 {
     this._netConnectionClient.Call(endpoint, destination, source, operation, callback, arguments);
 }
예제 #19
0
 /// <summary>
 /// Invoke clients with parameters and callback.
 /// </summary>
 /// <param name="method">Method name.</param>
 /// <param name="arguments">Invocation parameters passed to the method.</param>
 /// <param name="callback">Callback used to handle return values.</param>
 /// <param name="ignoreSelf">Current client shoud be ignored.</param>
 /// <param name="targetScope">Invoke clients subscribed to the specified Scope.</param>
 protected void InvokeClients(string method, object[] arguments, IPendingServiceCallback callback, bool ignoreSelf, IScope targetScope)
 {
     try
     {
         if (log.IsDebugEnabled)
             log.Debug(string.Format("Invoke clients: {0}", method));
         IServiceCapableConnection connection = FluorineFx.Context.FluorineContext.Current.Connection as IServiceCapableConnection;
         IEnumerator collections = targetScope.GetConnections();
         while (collections.MoveNext())
         {
             IConnection connectionTmp = collections.Current as IConnection;
             if (!connectionTmp.Scope.Name.Equals(targetScope.Name))
                 continue;
             if ((connectionTmp is IServiceCapableConnection) && (!ignoreSelf || connectionTmp != connection))
                 (connectionTmp as IServiceCapableConnection).Invoke(method, arguments, callback);
         }
     }
     catch (Exception ex)
     {
         if (log.IsErrorEnabled)
             log.Error("InvokeClients failed", ex);
         throw;
     }
     finally
     {
         if (log.IsDebugEnabled)
             log.Debug(string.Format("Finished invoking clients ({0})", method));
     }
 }
예제 #20
0
 /// <summary>
 /// Invoke clients with parameters and callback.
 /// </summary>
 /// <param name="method">Method name.</param>
 /// <param name="arguments">Invocation parameters passed to the method.</param>
 /// <param name="callback">Callback used to handle return values.</param>
 protected void InvokeClients(string method, object[] arguments, IPendingServiceCallback callback)
 {
     InvokeClients(method, arguments, callback, false);
 }
예제 #21
0
 /// <summary>
 /// Begins an asynchronous operation to invoke clients with parameters and callback.
 /// </summary>
 /// <param name="asyncCallback">The AsyncCallback delegate.</param>
 /// <param name="method">Method name.</param>
 /// <param name="arguments">Invocation parameters passed to the method.</param>
 /// <param name="callback">Callback used to handle return values.</param>
 /// <param name="ignoreSelf">Current client shoud be ignored.</param>
 /// <returns>An IAsyncResult that references the asynchronous invocation.</returns>
 /// <remarks>
 /// <para>
 /// The <i>asyncCallback</i> delegate identifies the callback invoked when the messages are sent, the <i>callback</i> object identifies the callback handling client responses.
 /// </para>
 /// <para>
 /// You can create a callback method that implements the AsyncCallback delegate and pass its name to the BeginInvokeClients method.
 /// </para>
 /// <para>
 /// Your callback method should invoke the EndInvokeClients method. When your application calls BeginInvokeClients, the system will use a separate thread to execute the specified callback method, and will block on EndInvokeClients until the clients are invoked successfully or throws an exception.
 /// </para>
 /// </remarks>
 protected IAsyncResult BeginInvokeClients(AsyncCallback asyncCallback, string method, object[] arguments, IPendingServiceCallback callback, bool ignoreSelf)
 {
     return BeginInvokeClients(asyncCallback, method, arguments, callback, ignoreSelf, this.Scope);
 }
예제 #22
0
 /// <summary>
 /// Invoke clients with parameters and callback.
 /// </summary>
 /// <param name="method">Method name.</param>
 /// <param name="arguments">Invocation parameters passed to the method.</param>
 /// <param name="callback">Callback used to handle return values.</param>
 /// <param name="ignoreSelf">Current client shoud be ignored.</param>
 protected void InvokeClients(string method, object[] arguments, IPendingServiceCallback callback, bool ignoreSelf)
 {
     InvokeClients(method, arguments, callback, ignoreSelf, this.Scope);
 }
예제 #23
0
 public CreateStreamCallBack(NetStream stream, RtmpConnection connection, IPendingServiceCallback callback)
 {
     ValidationUtils.ArgumentNotNull(connection, "connection");
     _stream = stream;
     _connection = connection;
     _callback = callback;
 }
예제 #24
0
 /// <summary>
 /// Begins an asynchronous operation to invoke clients with parameters and callback.
 /// </summary>
 /// <param name="asyncCallback">The AsyncCallback delegate.</param>
 /// <param name="method">Method name.</param>
 /// <param name="arguments">Invocation parameters passed to the method.</param>
 /// <param name="callback">Callback used to handle return values.</param>
 /// <returns>An IAsyncResult that references the asynchronous invocation.</returns>
 /// <remarks>
 /// <para>
 /// The <i>asyncCallback</i> delegate identifies the callback invoked when the messages are sent, the <i>callback</i> object identifies the callback handling client responses.
 /// </para>
 /// <para>
 /// You can create a callback method that implements the AsyncCallback delegate and pass its name to the BeginInvokeClients method.
 /// </para>
 /// <para>
 /// Your callback method should invoke the EndInvokeClients method. When your application calls BeginInvokeClients, the system will use a separate thread to execute the specified callback method, and will block on EndInvokeClients until the clients are invoked successfully or throws an exception.
 /// </para>
 /// </remarks>
 protected IAsyncResult BeginInvokeClients(AsyncCallback asyncCallback, string method, object[] arguments, IPendingServiceCallback callback)
 {
     return(BeginInvokeClients(asyncCallback, method, arguments, callback, false));
 }
예제 #25
0
		/// <summary>
		/// Invoke method by name with callback.
		/// </summary>
		/// <param name="method">Method name.</param>
		/// <param name="callback">Callback used to handle return values.</param>
		public void Invoke(string method, IPendingServiceCallback callback) {
			Invoke(method, null, callback);
		}
예제 #26
0
 /// <summary>
 /// Begins an asynchronous operation to invoke clients with parameters and callback.
 /// </summary>
 /// <param name="asyncCallback">The AsyncCallback delegate.</param>
 /// <param name="method">Method name.</param>
 /// <param name="arguments">Invocation parameters passed to the method.</param>
 /// <param name="callback">Callback used to handle return values.</param>
 /// <param name="ignoreSelf">Current client shoud be ignored.</param>
 /// <returns>An IAsyncResult that references the asynchronous invocation.</returns>
 /// <remarks>
 /// <para>
 /// The <i>asyncCallback</i> delegate identifies the callback invoked when the messages are sent, the <i>callback</i> object identifies the callback handling client responses.
 /// </para>
 /// <para>
 /// You can create a callback method that implements the AsyncCallback delegate and pass its name to the BeginInvokeClients method.
 /// </para>
 /// <para>
 /// Your callback method should invoke the EndInvokeClients method. When your application calls BeginInvokeClients, the system will use a separate thread to execute the specified callback method, and will block on EndInvokeClients until the clients are invoked successfully or throws an exception.
 /// </para>
 /// </remarks>
 protected IAsyncResult BeginInvokeClients(AsyncCallback asyncCallback, string method, object[] arguments, IPendingServiceCallback callback, bool ignoreSelf)
 {
     return(BeginInvokeClients(asyncCallback, method, arguments, callback, ignoreSelf, this.Scope));
 }
예제 #27
0
		/// <summary>
		/// Begins an asynchronous operation to invoke a service by name and with callback.
		/// </summary>
		/// <param name="asyncCallback">The AsyncCallback delegate.</param>
		/// <param name="method">Method name.</param>
		/// <param name="callback">Callback used to handle return values.</param>
		/// <returns>An IAsyncResult that references the asynchronous invocation.</returns>
		/// <remarks>
		/// <para>
		/// You can create a callback method that implements the AsyncCallback delegate and pass its name to the BeginInvoke method.
		/// </para>
		/// <para>
		/// Your callback method should invoke the EndInvoke method. When your application calls BeginInvoke, the system will use a separate thread to execute the specified callback method, and will block on EndInvoke until the client is invoked successfully or throws an exception.
		/// </para>
		/// </remarks>
		public IAsyncResult BeginInvoke(AsyncCallback asyncCallback, string method, IPendingServiceCallback callback) {
			return BeginInvoke(asyncCallback, method, null, callback);
		}
예제 #28
0
        /// <summary>
        /// Begins an asynchronous operation to invoke clients with parameters and callback.
        /// </summary>
        /// <param name="asyncCallback">The AsyncCallback delegate.</param>
        /// <param name="method">Method name.</param>
        /// <param name="arguments">Invocation parameters passed to the method.</param>
        /// <param name="callback">Callback used to handle return values.</param>
        /// <param name="ignoreSelf">Current client shoud be ignored.</param>
        /// <param name="targetScope">Invoke clients subscribed to the specified Scope.</param>
        /// <returns>An IAsyncResult that references the asynchronous invocation.</returns>
        /// <remarks>
        /// <para>
        /// The <i>asyncCallback</i> delegate identifies the callback invoked when the messages are sent, the <i>callback</i> object identifies the callback handling client responses.
        /// </para>
        /// <para>
        /// You can create a callback method that implements the AsyncCallback delegate and pass its name to the BeginInvokeClients method.
        /// </para>
        /// <para>
        /// Your callback method should invoke the EndInvokeClients method. When your application calls BeginInvokeClients, the system will use a separate thread to execute the specified callback method, and will block on EndInvokeClients until the clients are invoked successfully or throws an exception.
        /// </para>
        /// </remarks>
        protected IAsyncResult BeginInvokeClients(AsyncCallback asyncCallback, string method, object[] arguments, IPendingServiceCallback callback, bool ignoreSelf, IScope targetScope)
        {
            // Create IAsyncResult object identifying the asynchronous operation
            AsyncResultNoResult ar = new AsyncResultNoResult(asyncCallback, new InvokeData(FluorineContext.Current, method, arguments, callback, ignoreSelf, targetScope));

            // Use a thread pool thread to perform the operation
            FluorineFx.Threading.ThreadPoolEx.Global.QueueUserWorkItem(new System.Threading.WaitCallback(OnBeginInvokeClients), ar);
            // Return the IAsyncResult to the caller
            return(ar);
        }
예제 #29
0
 /// <summary>
 /// Invoke a method on the current connection and handle result.
 /// </summary>
 /// <param name="method">Name of the method to invoke.</param>
 /// <param name="args">Parameters to pass to the method.</param>
 /// <param name="callback">Object to notify when result is received.</param>
 /// <returns><code>true</code> if the connection supports method calls, otherwise <code>false</code></returns>
 public static bool InvokeOnConnection(string method, object[] args, IPendingServiceCallback callback)
 {
     IConnection connection = FluorineFx.Context.FluorineContext.Current.Connection;
     return InvokeOnConnection(connection, method, args, callback);
 }
예제 #30
0
        /// <summary>
        /// Invoke a method on the current connection and handle result.
        /// </summary>
        /// <param name="method">Name of the method to invoke.</param>
        /// <param name="args">Parameters to pass to the method.</param>
        /// <param name="callback">Object to notify when result is received.</param>
        /// <returns><code>true</code> if the connection supports method calls, otherwise <code>false</code></returns>
        public static bool InvokeOnConnection(string method, object[] args, IPendingServiceCallback callback)
        {
            IConnection connection = dotFlex.Context.FluorineContext.Current.Connection;

            return(InvokeOnConnection(connection, method, args, callback));
        }