Esempio n. 1
0
        public void DragStartWithData(object sender)
        {
            routerClient.Transmit(DRAG_START_CHANNEL, JArray.FromObject(emitters.Keys));
            var ret = DragDrop.DoDragDrop(sender as Control, emit().ToString(), DragDropEffects.Copy);

            routerClient.Transmit(DRAG_END_CHANNEL, new JObject {
            });
        }
Esempio n. 2
0
 public void HyperFocus(JObject parameters, EventHandler <FinsembleEventArgs> callback)
 {
     if (parameters["windowList"] == null && parameters["groupName"] == null && parameters["componentType"] == null)
     {
         parameters["windowList"] = new JArray();
         (parameters["windowList"] as JArray).Add(windowClient.windowIdentifier);
     }
     routerClient.Transmit("LauncherService.hyperFocus", parameters);
     callback(this, new FinsembleEventArgs(null, null));
 }
Esempio n. 3
0
 public void PublishToChannel(JToken channel, JObject parameters)
 {
     routerClient.Transmit((string)channel + '.' + (string)parameters["dataType"], new JObject
     {
         ["type"] = (string)parameters["dataType"],
         ["data"] = parameters["data"]
     });
     routerClient.Transmit((string)channel, new JObject
     {
         ["type"] = (string)parameters["dataType"],
         ["data"] = parameters["data"]
     });
 }
Esempio n. 4
0
        internal LauncherClient(Finsemble bridge)
        {
            this.bridge  = bridge;
            routerClient = bridge.RouterClient;
            windowClient = bridge.WindowClient;
            // Window Groups
            windowClient.GetComponentState(new JObject
            {
                ["field"] = "finsemble:windowGroups"
            }, (err, groups) => {
                if (groups.response != null)
                {
                    AddToGroups(new JObject
                    {
                        ["groupNames"] = groups.response
                    }, SubscribeToGroupUpdates);
                }
            });

            // Heartbeat
            timer.Interval = 1000;
            timer.Elapsed += (sender, e) => {
                routerClient.Transmit("Finsemble.heartbeat", new JObject
                {
                    ["type"]          = "component",
                    ["componentType"] = "finsemble",
                    ["windowName"]    = bridge.windowName
                });
            };
            timer.Enabled = true;
        }
 /// <summary>
 /// During Finsemble's start-up process, this function must be invoked before Finsemble will start the application.
 /// Once invoked, the authenticated user name and authorization credentials are received by the Authentication Service and published on the "AuthenticationService.authorization" channel.
 /// Any component can revieve the credentials by subscribing to that channel or by calling GetCurrentCredentials.
 /// Note that all calls to Storage Client are keyed to the authenticated *user*. See StorageClient.SetUser.
 /// If authentication is not enabled, then "defaultUser" is used instead.
 /// </summary>
 /// <param name="user">Username</param>
 /// <param name="credentials">Object containing user credentials</param>
 public void PublishAuthorization <T>(string user, T credentials)
 {
     routerClient.Transmit("AuthenticationService.authorization", new JObject
     {
         ["user"]        = user,
         ["credentials"] = JObject.FromObject(credentials)
     });
 }
Esempio n. 6
0
        private void formatAndSendMessage(string category, string type, params JToken[] args)
        {
            var message = new JObject
            {
                ["category"]      = category,
                ["logClientName"] = bridge.windowName,
                ["logType"]       = type,
                ["logData"]       = JArray.FromObject(args).ToString(),
                ["logTimestamp"]  = (Int64)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds
            };

            routerClient.Transmit("logger.service.logMessages", new JArray
            {
                message
            });
        }
Esempio n. 7
0
 public void ShutdownApplication()
 {
     RouterClient.Transmit("Application.shutdown", new JObject {
     });
 }
Esempio n. 8
0
        private void Disconnect()
        {
            if (disconnecting)
            {
                return;
            }

            disconnecting = true;
            Logger.Info("Disconnect called");

            // Clean up clients that require disposing
            try
            {
                if (logger != null)
                {
                    logger.Dispose();
                }
            }
            catch
            { }
            finally
            {
                logger = null;
            }

            try
            {
                if (LauncherClient != null)
                {
                    LauncherClient.Dispose();
                }
            }
            catch
            { }
            finally
            {
                LauncherClient = null;
            }

            try
            {
                if (RouterClient != null)
                {
                    RouterClient.Transmit("Finsemble.Assimilation.closed." + this.windowName, true);
                    RouterClient.Dispose();
                }
            }
            catch { }
            finally { }

            // Close appropriate connection


            if (socket != null)
            {
                socket.Close();
                socket = null;
            }

            // Notify listeners bridge is disconnected from OpenFin
            Disconnected?.Invoke(this, EventArgs.Empty);
        }
Esempio n. 9
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");
            }
        }
Esempio n. 10
0
 private void Window_Activated(object sender, EventArgs e)
 {
     routerClient.Transmit(dockingWindowName + ".focused", new JObject {
     });
 }