/// <summary> /// Add a listener that fires when a specific value in a store is changed. /// </summary> /// <example> /// <code> /// store.RemoveListener(new JObject {["field"] = "field1"}, myHandler); /// </code> /// </example> /// <param name="parameters"></param> /// <param name="callback"></param> public void RemoveListener(JObject parameters, EventHandler <FinsembleEventArgs> callback) { string field; if (parameters != null) { field = name + "." + (string)parameters["field"]; //TODO: add ability to add global listener } else { field = ""; } routerClient.Unsubscribe("storeService" + field, callback); }
private void RPC(string endpoint, List <JToken> args, EventHandler <FinsembleEventArgs> cb) { switch (endpoint) { case "RouterClient.transmit": RouterClient.Transmit((string)args[0], args[1]); break; case "RouterClient.addListener": RouterClient.AddListener((string)args[0], cb); break; case "RouterClient.removeListener": RouterClient.RemoveListener((string)args[0], cb); break; case "RouterClient.publish": RouterClient.Publish((string)args[0], args[1]); break; case "RouterClient.subscribe": RouterClient.Subscribe((string)args[0], cb); break; case "RouterClient.unsubscribe": RouterClient.Unsubscribe((string)args[0], cb); break; case "RouterClient.query": RouterClient.Query((string)args[0], args[1], args[2] as JObject, cb); break; case "LinkerClient.publish": LinkerClient.Publish(args[0] as JObject); break; case "LinkerClient.subscribe": LinkerClient.Subscribe((string)args[0], cb); break; case "LauncherClient.spawn": LauncherClient.Spawn((string)args[0], args[1] as JObject, cb); break; case "LauncherClient.showWindow": LauncherClient.ShowWindow(args[0] as JObject, args[1] as JObject, cb); break; case "ConfigClient.getValue": ConfigClient.GetValue(args[0] as JObject, cb); break; case "AuthenticationClient.publishAuthorization": authenticationClient.PublishAuthorization <JObject>((string)args[0], args[1] as JObject); break; case "AuthenticationClient.getCurrentCredentials": authenticationClient.GetCurrentCredentials <JObject>((s, a) => { cb(this, new FinsembleEventArgs(null, a)); }); break; case "Logger.error": JToken[] argsArray = args.ToArray(); logger.Error(argsArray); break; case "Logger.warn": logger.Warn(args.ToArray()); break; case "Logger.log": logger.Log(args.ToArray()); break; case "Logger.info": logger.Info(args.ToArray()); break; case "Logger.debug": logger.Debug(args.ToArray()); break; case "Logger.verbose": logger.Verbose(args.ToArray()); break; default: throw new Exception("This API does not exist or is not yet supported"); } }