public CommandMessage(object cmd, object args, AckCallback callback) : base(MessageType.Command, args) { AckHandler = callback; WantAck = true; Command = cmd; }
public void onReady() { setConnectButtonState("Disconnect", true, true); interAppBus_ = controller_.getInterApplicationBus(); interAppBus_.addSubscribeListener((uuid, topic) => { bool exists = false; if (!subscriptionMap.TryGetValue(topic, out exists)) { subscriptionMap.Add(topic, true); if (subscriptionCallback != null) { subscriptionCallback(); } } }); Console.WriteLine("OnReady."); ApplicationOptions mainAppOptions = new ApplicationOptions(htmlDemoUuid_, htmlDemoUuid_, "https://developer.openf.in/htmlinterappcommdemo/1/index.html"); mainAppOptions.Version = "v1.0.0.0b"; mainAppOptions.IsAdmin = true; WindowOptions mainWindowOptions = mainAppOptions.MainWindowOptions; mainWindowOptions.AutoShow = true; mainWindowOptions.DefaultLeft = 100; mainWindowOptions.DefaultTop = 100; mainWindowOptions.DefaultWidth = 510; mainWindowOptions.DefaultHeight = 350; mainWindowOptions.Maximizable = false; mainWindowOptions.ShowTaskbarIcon = true; AckCallback afterAppCreation = (ack) => { Console.WriteLine("afterAppCreation"); Console.WriteLine(ack.getJsonObject().ToString()); AckCallback afterRun = (runAck) => { Console.WriteLine("afterRun"); Console.WriteLine(runAck.getJsonObject().ToString()); }; Console.WriteLine("app.run()"); // Using same callback for success and error in case app is already running htmlApplication_.run(afterRun, afterRun); }; // Using same callback for success and error in case app already exists Console.WriteLine("Creating App"); htmlApplication_ = new Application(mainAppOptions, controller_, afterAppCreation, afterAppCreation); htmlApplication_.addEventListener("closed", (ack) => { controller_.disconnect(); System.Windows.Forms.Application.ExitThread(); }); }
// // Summary: // Callback when Desktop is successfully connected and ready to accept commands. public void onReady() { Openfin.Desktop.ApplicationOptions appOptions = new Openfin.Desktop.ApplicationOptions(parentAppUuid_, parentAppUuid_, url_); Openfin.Desktop.WindowOptions windowOptions = appOptions.MainWindowOptions; windowOptions.AutoShow = true; windowOptions.DefaultWidth = 310; windowOptions.DefaultHeight = 287; AckCallback afterCreate = (createAck) => { htmlApp_.run((runAck) => { // Handle on UI thread to get the window bounds this.Dispatcher.BeginInvoke(new Action(() => { htmlApp_.getWindow().showAt((int)Left + (int)Width + 80, (int)Top, false); htmlApp_.getWindow().setAsForeground(); // Subscribe to handle when this app has been registered with the HTML app connection_.getInterApplicationBus().subscribe(parentAppUuid_, "csharp-registered", (sourceUuid, topic, message) => { // Handle on UI thread to check externalObserver_ is not defined this.Dispatcher.BeginInvoke(new Action(() => { if (externalObserver_ == null) { // Integrate this window externalObserver_ = new Openfin.Desktop.ExternalWindowObserver(host_, port_, parentAppUuid_, name_, new WindowInteropHelper(this).Handle); } })); }); // Ensure HTML is ready before registering. connection_.getInterApplicationBus().subscribe(parentAppUuid_, "html-wpf-ready", (rSourceUuid, rTopic, rMessage) => { // Be on UI thread to ensure externalObserver_ is not defined this.Dispatcher.BeginInvoke(new Action(() => { // Notify HTML to register and prepare for docking with this C# app if (externalObserver_ == null) { JObject payload = new JObject(); DesktopUtils.updateJSONValue(payload, "name", name_); connection_.getInterApplicationBus().send(parentAppUuid_, "reserve-csharp-name", payload); } })); }); connection_.getInterApplicationBus().send(parentAppUuid_, "wpf-html-ready", null); })); }); }; htmlApp_ = new Openfin.Desktop.Application(appOptions, connection_, afterCreate, afterCreate); }
void UpdateOptionsRaw(this Window window, object options, AckCallback ack, AckCallback nak) { var app = window.Application; var runtime = app.Runtime; var payload = new JObject(); payload["uuid"] = app.Uuid; payload["name"] = window.Name; payload["options"] = JObject.FromObject(options); runtime.DesktopConnection.sendAction("update-window-options", payload, ack, nak); }
public void Emit(string eventName, IJsonValue args, AckCallback ackCallback) { SIO_Packet p = new SIO_Packet(SIO_Packet.PacketType.EVENT); p.Namespace = Name; if (args.ValueType == JsonValueType.Array) { args.GetArray().Insert(0, JsonValue.CreateStringValue(eventName)); p.Data = args; } else { var data = new JsonArray(); data.Add(JsonValue.CreateStringValue(eventName)); data.Add(args); p.Data = data; } client.Send(p.Encode()); }
public void Emit(string eventName, IJsonValue args, AckCallback ackCallback) { rootNamespace.Emit(eventName, args, ackCallback); }