Пример #1
0
 public void RPC(string endpoint, List <JToken> args, RPCCallbackHandler cb = null)
 {
     RPC(endpoint, args, (s, a) =>
     {
         cb?.Invoke(a.error, a.response);
     });
 }
Пример #2
0
        /// <summary>
        /// Use this command to execute Finsemble API calls remotely. Specify all the arguments as a list and the callback for the callback or eventHandler.
        ///
        /// Supported API Calls:
        /// <list type="bullet">
        /// <item><term>RouterClient.transmit: </term> <description>same as JavaScript API</description></item>
        /// <item><term>RouterClient.addListener: </term> <description>same as JavaScript API</description></item>
        /// <item><term>RouterClient.removeListener: </term> <description>same as JavaScript API</description></item>
        /// <item><term>RouterClient.publish: </term> <description>same as JavaScript API</description></item>
        /// <item><term>RouterClient.subscribe: </term> <description>does not return a subscribeID</description></item>
        /// <item><term>RouterClient.unsubscribe: </term> <description>takes parameters["topic"] and the same callback that was passed to subscribe.</description></item>
        /// <item><term>RouterClient.query: </term> <description>same as JavaScript API</description></item>
        /// <item><term>LinkerClient.publish: </term> <description>does not use the callback, does not support the channels option.</description></item>
        /// <item><term>LinkerClient.subscribe: </term> <description>same as JavaScript API</description></item>
        /// <item><term>LauncherClient.spawn: </term> <description>same as JavaScript API</description></item>
        /// <item><term>LauncherClient.showWindow: </term> <description>same as JavaScript API</description></item>
        /// <item><term>ConfigClient.getValue: </term> <description>same as JavaScript API</description></item>
        /// </list>
        /// </summary>
        /// <example>
        /// <code>
        /// /* The router transmit API has two parameters, toChannel and event */
        /// finsemble.SendRPCMessage("RouterClient.transmit", new List&lt;JToken&gt; {
        ///     "channel",
        ///     new JObject {
        ///         ["myData"] = "myData"
        ///     }
        /// }, (s, args) => {});
        ///
        /// finsemble.SendRPCMessage("RouterClient.subscribe", new List&lt;JToken&gt; {
        ///     "myTopic"
        /// }, mySubHandler);
        ///
        /// finsemble.SendRPCMessage("RouterClient.unsubscribe", new List&lt;JToken&gt; {
        ///     "myTopic"
        /// }, mySubHandler);
        ///
        /// /* Linker.publish takes params */
        /// finsemble.SendCommand("LinkerClient.publish", new List&lt;JToken&gt; {
        ///     new JObject {
        ///         ["dataType"] = "myType",
        ///         ["data"] = new JObject {
        ///             ["property1"] = "property"
        ///         }
        ///     }
        /// }, (s, args) => {});
        /// </code>
        /// </example>
        /// <param name="endpoint">Name of the API call from the list above</param>
        /// <param name="args">This is a JObject which contains all the parameters that the API call takes. Refer to our JavaScript API for the parameters to each API call.</param>
        /// <param name="cb">If the API has a callback, this will be used to call back.</param>
        public void RPC(string endpoint, JArray args, RPCCallbackHandler cb = null)
        {
            var l = new List <JToken>();

            foreach (var item in args)
            {
                l.Add(item);
            }
            RPC(endpoint, l, (s, a) =>
            {
                cb?.Invoke(a.error, a.response);
            });
        }