public Program(JObject consumerConfig, JObject adminConfig) { // load information about the local client Arrowhead.Utils.Settings settings = new Arrowhead.Utils.Settings(consumerConfig); this.client = new Arrowhead.Client(settings); // Load information about the Provider System that this Client wants to consume Arrowhead.Utils.Settings adminSettings = new Arrowhead.Utils.Settings(adminConfig); this.admin = new Arrowhead.Admin(adminSettings); // creates orchestration information between this client system and // the system that has been configured in the Admin Config this.admin.StoreOrchestrate(this.client.GetSystemId()); // start orchestration between this client and a producer that this client has the rights to consume JArray orchestrations = this.client.Orchestrate(); JObject orchestration = (JObject)orchestrations[0]; this.producerHost = orchestration.SelectToken("provider.address").ToString(); this.producerPort = orchestration.SelectToken("provider.port").ToString(); this.serviceUri = orchestration.SelectToken("serviceUri").ToString(); JArray interfaces = (JArray)orchestration.SelectToken("interfaces"); if (interfaces[0].SelectToken("interfaceName").ToString() == "HTTPS-SECURE-JSON") { producerSSL = true; } else { producerSSL = false; } Console.WriteLine("Orchestration against http" + (producerSSL ? "s://" : "://") + this.producerHost + ":" + this.producerPort + this.serviceUri + " was started"); }
public Program(JObject config) { // load information about the local client Arrowhead.Utils.Settings settings = new Arrowhead.Utils.Settings(config); // creating the client registers it in the Service Register this.client = new Arrowhead.Client(settings); bool useSSL = settings.Interfaces.Any(i => i == "HTTPS-SECURE-JSON"); using (var server = new RestServer()) { server.UseHttps = useSSL; server.Host = config.SelectToken("system.ip").ToString(); server.Port = config.SelectToken("system.port").ToString(); server.LogToConsole().Start(); Console.ReadLine(); server.Stop(); } }