Beispiel #1
0
        private void Connect(object sender, bool connected)
        {
            // Do not attempt to connect more than once. This causes the Window to close prematurely from responders firing because of errors.
            if (isFinsembleConnected)
            {
                return;
            }
            isFinsembleConnected = true;

            logger               = new Logger(this);
            storageClient        = new StorageClient(this);
            authenticationClient = new AuthenticationClient(this);
            ConfigClient         = new ConfigClient(this);
            ShareClient          = new Share(this);
            ConfigClient.GetValue(new JObject
            {
                ["field"] = "finsemble.components." + this.componentType
            }, (s, a) =>
            {
                if (!(a.response["data"] is JObject))
                {
                    // Data isn't a JObject
                    //logger.Warn(string.Format(
                    //"Response data object does not have the correct type. Type: \"{0}\", Value: \"{1}\"",
                    ////a.response["data"].GetType().ToString(),
                    //a.response["data"].ToString()));
                }

                this.componentConfig = a.response["data"] as JObject;
                if (this.componentConfig == null)
                {
                    this.componentConfig = new JObject();
                }
                WindowClient           = new WindowClient(this);
                LauncherClient         = new LauncherClient(this);
                distributedStoreClient = new DistributedStoreClient(this);
                if (window != null)
                {
                    DragAndDropClient = new DragAndDropClient(this);
                }
                if (window != null)
                {
                    docking = new Docking(this, windowName + "-channel");
                }

                LinkerClient = new LinkerClient(this, (s2, a2) =>
                {
                    Connected?.Invoke(this, EventArgs.Empty);
                });

                // Notify listeners that connection is complete.
                // ToDo, wait for clients to be ready??
            });
        }
Beispiel #2
0
        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");
            }
        }