kdcllc / CometD.NetCore.Salesforce

CometD Salesforce Implementation.
MIT License
45 stars 24 forks source link

Need help getting a simple example running. #39

Open bzuidgeest opened 2 years ago

bzuidgeest commented 2 years ago

I'm trying to use the code in this repo to follow this tutorial: https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/code_sample_java_create_pushtopic.htm

But I am at a loss on how to exactly use the library. I have the streamingclient and I do a subscribetopic. But nothing happens. The state on the client seems to be disconnected. I expected to see some events happening. But I cannot find anything to make it connect. There seems to be a disconnect function but not a connect function.

Any help appreciated.

cobbled together stuff ` var host = new HostBuilder() .ConfigureHostConfiguration(configHost => { configHost.SetBasePath(Directory.GetCurrentDirectory()); configHost.AddJsonFile("hostsettings.json", optional: true); configHost.AddEnvironmentVariables(prefix: "TESTAPP_"); configHost.AddCommandLine(args); }) .ConfigureAppConfiguration((hostContext, configBuilder) => { configBuilder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); configBuilder.AddJsonFile( $"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true);

                 //configBuilder.AddAzureKeyVault(hostingEnviromentName: hostContext.HostingEnvironment.EnvironmentName);

                 configBuilder.AddEnvironmentVariables(prefix: "TESTAPP_");
                 configBuilder.AddCommandLine(args);

                 if (hostContext.HostingEnvironment.IsDevelopment())
                 {
                     // print out the environment
                     var config = configBuilder.Build();
                     //config.DebugConfigurations();
                 }
             })
             .ConfigureServices((context, services) =>
             {
                 services.AddResilientStreamingClient("Salesforce");

                 // Conjure up a RequestServices
                 services.AddTransient<IServiceProviderFactory<IServiceCollection>, DefaultServiceProviderFactory>();
             })
             .ConfigureLogging((hostContext, configLogging) =>
             {
                 configLogging.AddConfiguration(hostContext.Configuration.GetSection("Logging"));
                 configLogging.AddConsole();
                 configLogging.AddDebug();
             })
             .UseConsoleLifetime()
             .Build();

        var sp = host.Services;

        IStreamingClient x = sp.GetRequiredService<IStreamingClient>();

        x.SubscribeTopic("/InvoiceStatementUpdates", new MyListener(), -2);

        await host.RunAsync();

`

bzuidgeest commented 2 years ago

I got the example from https://ballardsoftware.com/getting-started-with-the-salesforce-streaming-api-in-net-core/ working combined with https://www.forcetalks.com/blog/how-to-integrate-salesforce-streaming-api-with-net-core-application/

Both use the CometD library from kdcllc that is libray (CometD.NetCore.Salesforce) is based on. So I am missing somthing in this library required to make it connect. Where is the "Connect" function?