Пример #1
0
 /// <summary>
 /// Perform a remote method invocation on the referenced service, with a self-specified due time.
 /// The due time is the amount of time (in milliseconds) during with the remote method invocation should complete
 /// Otherwise the future is ruined
 /// </summary>
 /// <param name="message">Object containing both the method name (in string form) and the due time</param>
 /// <param name="parameters">Arguments for the remote method </param>
 /// <returns>Returns a Future, which can be used to monitor the return value</returns>
 public Future AsyncInvoke(MessageSelector message, params object[] parameters)
 {
     return EventLoop.Instance.discoveryManager.RemoteMethodInvocation(this, message, parameters);
 }
Пример #2
0
        /// <summary>
        /// Perform a remote method invocation on a remote object
        /// </summary>
        /// <param name="objectReference">The RemoteReference to the object on which to perform the remote method invocation</param>
        /// <param name="selector">Object containing the name of the method we wish to invoke, in string form, e.g. "GetName" and the due time</param>
        /// <param name="parameters">The array of parameters which are required by the to-be-invoked method</param>
        /// <returns>Returns a future, or a "future that we'll try to get you a return value at some point in the future"</returns>
        public Future RemoteMethodInvocation(RemoteReference objectReference, MessageSelector selector, object[] parameters)
        {
            System.Diagnostics.Debug.WriteLine(String.Format("PERFORMED RMI: {0}, {1}", selector, objectReference.sourceAddress));

            // Convert all parameters of type UObject to a RemoteReference (pass-by-reference for UObjects)
            for (int i = 0; i < parameters.Length; i++)
                if (parameters[i] is UObject)
                    parameters[i] = this.serviceManager.exportedServiceManager.AddParameterReferencedObject(parameters[i]);

            // Create a new future. We add a reference (the guid) of this future to the method invocation, so we know a return value belongs to this future
            Future future = new Future(objectReference.guid);
            // Create the data packet to send over the network
            NetworkRemoteMethodInvocation networkObject = new NetworkRemoteMethodInvocation(objectReference.guid, future.guid, selector.selector, parameters);
            // Enqueue it in the outgoing queue
            this.eventQueueOutgoing.Enqueue(objectReference.sourceAddress, networkObject, selector.due);

            return future;
        }