private void ConnectToChannel() { ChannelConnectOptions opts = new ChannelConnectOptions(ChannelName) { Wait = true, Payload = "Hello from donet" }; _channelClient = _fin.InterApplicationBus.Channel.CreateClient(opts); _channelClient.Opened += ChannelClient_Opened; _channelClient.Closed += ChannelClient_Closed; _channelClient.ConnectAsync(); }
internal static void Initialize(Runtime runtimeInstance) { intentListeners = new Dictionary <string, Action <ContextBase> >(); channelClient = runtimeInstance.InterApplicationBus.Channel.CreateClient(Fdc3ServiceConstants.ServiceChannel); registerChannelTopics(); channelClient.ConnectAsync().ContinueWith(x => { if (x.Exception == null) { ConnectionInitializationComplete?.Invoke(x.Exception); } }); }
internal Task InitializeAsync() { if (!string.IsNullOrEmpty(ConnectionManager.RuntimeInfo.FDC3ChannelName)) { channelClient = ConnectionManager.RuntimeInstance.InterApplicationBus.Channel.CreateClient(ConnectionManager.RuntimeInfo.FDC3ChannelName, connectionAlias); } else { channelClient = ConnectionManager.RuntimeInstance.InterApplicationBus.Channel.CreateClient(Fdc3ServiceConstants.ServiceChannel, connectionAlias); } registerChannelTopics(); return(channelClient.ConnectAsync()); }
private OpenFinProxy() { string unique = Guid.NewGuid().ToString(); _runtime = Runtime.GetRuntimeInstance(new RuntimeOptions { //Version = "19.89.60.5", Version = "18.87.55.19" //UUID = unique //ProcessHelper.IsOms ? EzeOMSUuid : NonEzeOMSUuid }); // get command line args, check to see if we’re running as the “server” string[] commandLine = Environment.GetCommandLineArgs(); bool isChannelProvider = bool.Parse(commandLine[1]); _runtime.Connect(async() => { Console.WriteLine("----------------------- Application connected to OpenFin -----------------------"); if (isChannelProvider) { _channelProvider = _runtime.InterApplicationBus.Channel.CreateProvider("1"); _channelProvider.RegisterTopic <string>("SayHello", (payload) => { return($"Hello {payload}!"); }); Console.WriteLine("----------------------- Channel 1 created -----------------------"); } else { // "may" be an issue //_channelClient = _runtime.InterApplicationBus.Channel.CreateClient(new ChannelConnectOptions("1") //{ // Wait = true //}); _channelClient = _runtime.InterApplicationBus.Channel.CreateClient("1"); await _channelClient.ConnectAsync(); // await here never finishes, and without connection, the sub/pub fails Debugger.Launch(); Console.WriteLine("----------------------- ChannelClient created -----------------------"); } IsConnected = true; }); }
/// <summary> /// Initializes the Notification Service. /// </summary> /// <param name="manifestUri">The Uri pointing to the notification service manifest.</param> public static void Initialize(Uri manifestUri) { if (OnInitComplete == null) { throw new InvalidOperationException("InitializationComplete handler must be registered before calling Initialize()"); } var runtimeOptions = RuntimeOptions.LoadManifest(manifestUri); runtimeOptions.Arguments += " --inspect"; var entryAssembly = System.Reflection.Assembly.GetEntryAssembly(); if (entryAssembly != null) { var productAttributes = entryAssembly.GetCustomAttributes(typeof(System.Reflection.AssemblyProductAttribute), true); if (productAttributes.Length > 0) { runtimeOptions.UUID = ((System.Reflection.AssemblyProductAttribute)productAttributes[0]).Product; } else { runtimeOptions.UUID = System.Reflection.Assembly.GetEntryAssembly().GetName().Name; } } else { runtimeOptions.UUID = Guid.NewGuid().ToString(); } _runtime = Runtime.GetRuntimeInstance(runtimeOptions); _runtime.Connect(() => { var notificationsService = _runtime.CreateApplication(runtimeOptions.StartupApplicationOptions); notificationsService.isRunning( async ack => { if (!(bool)(ack.getData() as JValue).Value) { notificationsService.run(); } _channelClient = _runtime.InterApplicationBus.Channel.CreateClient(ServiceConstants.NotificationServiceChannelName); _channelClient.RegisterTopic <NotificationEvent>(ChannelTopics.Events, (@event) => { switch (@event.EventType) { case NotificationEventTypes.NotificationAction: NotificationActionOccurred?.Invoke(@event); break; case NotificationEventTypes.NotificationClosed: NotificationClosed?.Invoke(@event); break; case NotificationEventTypes.NotificationCreated: NotificationCreated?.Invoke(@event); break; default: throw new ArgumentException($"Invalid event type : {@event.EventType}"); } }); await _channelClient.ConnectAsync(); await _channelClient.DispatchAsync(ApiTopics.AddEventListener, NotificationEventTypes.NotificationAction); OnInitComplete.Invoke(); }); }); }
private void ChannelClient_Closed(object sender, EventArgs e) { Console.WriteLine("channel disconnected"); _channelClient.ConnectAsync(); }