static void Main(string[] args) { CloudConnectionConfig cloudConnectionConfig = ConnectionConfigManager.GetConnectionConfig(); CloudConnector cloudConnector = new CloudConnector(cloudConnectionConfig); Console.WriteLine("Enter 1 for Publish. 2 for subscribe."); string input = Console.ReadLine(); if (input == "1") { cloudConnector.PublishMessage(); } else if (input == "2") { cloudConnector.SubscribeMessage(); } Console.ReadLine(); }
static async Task Main(string[] args) { CloudConnectionConfig cloudConnectionConfig = CloudConnectionConfig.Instance; CloudConnector cloudConnector = new CloudConnector(cloudConnectionConfig); string topic = "mytest/topic"; string message = "Test message"; int i = 0; await cloudConnector.ConnectToAwsIoT(); while (true) { Console.WriteLine("Enter 1 for publish. 2 for subscribe."); string input = Console.ReadLine(); if (input == "1") { await cloudConnector.PublishMessage($"{message} {i}", topic); } else if (input == "2") { await cloudConnector.SubscribeTo(topic); } i++; } }
public Connector.Connector GetConnector() { if (!_appConfig.Saas) { return(OnPremConnector.GetOrCreate(_appConfig.ClusterUrl)); } return(CloudConnector.GetOrCreate(_appConfig.ClusterUrl)); }
public async Task <ActionResult> Post([FromBody] VoucherGenerationSettings settings) { var c = new CloudConnector(new CloudLogin() { Username = Settings.CloudOmadaUser, Password = Settings.CloudOmadaPassword }); await c.LoginAsync(); //Check if Id is specified in request, then in AppSettings, then check if user only has one controller. //If nothing matches, return error. if (string.IsNullOrEmpty(settings.CloudClientId)) { if (string.IsNullOrEmpty(Settings.CloudOmadaClientId)) { var controllers = await c.GetCloudControllersAsync(); if (controllers.Count != 1) { return(BadRequest("CloudClientId not specified")); } else { settings.CloudClientId = controllers.Single().Id; } } else { settings.CloudClientId = Settings.CloudOmadaClientId; } } await c.LoginAsync(); c.DefaultCloudControllerId = settings.CloudClientId; await c.ConnectToCloudControllerAsync(); var vouchers = await c.GenerateVouchersAsync(settings.ToNewVoucherParams()); return(new JsonResult(vouchers)); }