public static int GetClientSession(
            this ILifelistService LifelistService,
            string address,
            string configName,
            string accessibleName,
            out ICoreObject AccessibleNode,
            ConnectionOpenedEventHandler connectionOpenedEventHandler = null
            )
        {
            ICoreObjectCollection boardConfigurations = ((IOnlineConfiguration)LifelistService.GetIConnectionService()).GetUsableConfigurations("OMS");
            ICoreObject           boardConfiguration  = LifelistService.GetBoardConfigurationByName(configName);


            ICoreObjectCollection accessibleNodes = LifelistService.GetAccessibleNodes(boardConfiguration, true);
            var names = accessibleNodes.GetNames();

            if (names.Contains(accessibleName))
            {
                AccessibleNode = accessibleNodes.GetCoreObjectByName(accessibleName);
                Type t            = AccessibleNode.GetType();
                var  onlineObject = LifelistService.GetOnlineNode(AccessibleNode);

                var connection = onlineObject.GetConnectionServiceProvider();
                var ConnectionServiceProviderProxy = new ConnectionServiceProviderProxy(connection);
                ConnectionServiceProviderProxy.ConnectionOpened += connectionOpenedEventHandler;

                IOamAddress oamAddress;
                int         createResult = OamObjectCreatorProxy.CreateAddress(address, out oamAddress);

                TargetConnectionInfo TargetConnectionInfo =
                    new TargetConnectionInfo(boardConfiguration, null, null, oamAddress);

                connection.SetTargetConnectionPath(onlineObject, TargetConnectionInfo);
                IConnection omsc = connection.ConnectToOnline(onlineObject, "OMS",
                                                              OnlineConnectionModes.UseTargetConnectionInfo,
                                                              TargetConnectionInfo);
                return(0);
            }
            AccessibleNode = null;
            return(-1);
        }
        public async Task ConnectionLifecycleEventHandler()
        {
            var    count = 0;
            object eventSender = null, eventArgs = null;

            var handler = new ConnectionOpenedEventHandler((sender, args) =>
            {
                eventSender = sender;
                eventArgs   = args;
                count++;
                return(new ValueTask());
            });

            var client = Mock.Of <IHazelcastClient>();
            var args   = new ConnectionOpenedEventArgs(true);
            await handler.HandleAsync(client, args);

            Assert.That(count, Is.EqualTo(1));
            Assert.That(eventSender, Is.SameAs(client));
            Assert.That(eventArgs, Is.SameAs(args));
        }