public WebHookEngine(RoomieEngine roomieController, string computerName, string communicationUrl, string accessKey, string encryptionKey) { this.roomieController = roomieController; this.computerName = computerName; this.communicationUrl = communicationUrl; this.accessKey = accessKey; this.encryptionKey = encryptionKey; //TODO: reintroduce multiple webhook engines? string threadPoolName = "Web Hook (to " + communicationUrl + ")"; //int engineCount = Common.GetWebHookEngines(this.roomieController).Count; //if (engineCount > 0) // threadPoolName += "(" + engineCount + ")"; this.threadPool = roomieController.CreateThreadPool(threadPoolName); this.running = false; communicator = new WebCommunicator.CommunicatorClient(communicationUrl, accessKey, encryptionKey); bool serverFound = false; while (!serverFound) { try { print("pinging Webhook server at " + communicationUrl + "..."); Message pingResponse = communicator.PingServer(); //TODO: should we look at the result? print("Webhook server found!"); serverFound = true; } catch (CommunicationException exception) { print("Error contacting server: " + exception.Message); System.Threading.Thread.Sleep(new TimeSpan(0, 0, 10)); } } ////initialize connection //Dictionary<string, string> sendValues = new Dictionary<string, string>(1); //sendValues.Add("action", "start session"); //sendValues.Add("ComputerName", computerName); //SecureHttpCommunication.RecievedPackage package = SendMessage(sendValues, null); //if (package.HasErrorMessage) // throw new ScriptException("Error starting webhook session"); //foreach (SecureHttpCommunication.Message message in package) //{ // if (message.ContainsParameter("NewSessionToken")) // sessionToken = message.GetValue("NewSessionToken"); // break; //} //if (String.IsNullOrEmpty(sessionToken)) // throw new ScriptException("Did not recieve a new SessionID"); //print("Webhook Session Token: " + sessionToken); events = new Queue<OutputEvent>(); //TODO: make this work! //this.roomieController.ScriptMessageSent += new Scope scopeScriptMessageEventHandler(roomieController_ScriptMessageSent); }
public RoomieThread(RoomieEngine engine, string name, HierarchicalVariableScope parentScope) { Engine = engine; Id = Guid.NewGuid().ToString(); Name = name; _interpreter = new RoomieCommandInterpreter(this, parentScope ?? Engine.GlobalScope); _workQueue = new ParallelWorkQueue(); }
public HomeAutomationNetworkContext(RoomieEngine engine, ThreadPool threadPool, IDeviceHistory deviceHistory, INetworkHistory networkHistory) { _engine = engine; ThreadPool = threadPool; //TODO: ninject? History = new MasterHistory(deviceHistory, networkHistory); Triggers = new TriggerCollection(); }
public RoomieThread(RoomieEngine engine, string name, HierarchicalVariableScope parentScope) { Engine = engine; Id = Guid.NewGuid().ToString(); Name = name; _interpreter = new RoomieCommandInterpreter(this, parentScope ?? Engine.GlobalScope); _workQueue = new ParallelWorkQueue(); }
public RoomieEventTextStream(RoomieEngine engine, TextWriter output, TimeSpan timeStampInterval) { this.output = output; this.timeStampInterval = timeStampInterval; _lastTimestamp = DateTime.MinValue; _lastThread = null; engine.ScriptMessageSent += new RoomieThreadEventHandler(engine_ScriptMessageSent); }
public RoomieEventTextStream(RoomieEngine engine, TextWriter output, TimeSpan timeStampInterval) { this.output = output; this.timeStampInterval = timeStampInterval; _lastTimestamp = DateTime.MinValue; _lastThread = null; engine.ScriptMessageSent += new RoomieThreadEventHandler(engine_ScriptMessageSent); }
public MainWindow() { InitializeComponent(); _engine = new RoomieEngine(); Events = new ObservableCollection<RoomieEvent>(); _engine.ScriptMessageSent += engine_ScriptMessageSent; _engine.EngineStateChanged += _engine_EngineStateChanged; EventListing.ItemsSource = Events; AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; }
static void Main(string[] args) { var engine = new RoomieEngine(); setOutput(engine); //engine.TerminalMessageSent += new TerminalOutputEventHandler(controller_TerminalMessageSent); engine.Start(); var line = ""; var input = ""; var xmlInput = new XmlDocument(); //TODO: improve this. Make the while loop directly depend on the engine's internal state. while (!input.Contains("Core.ShutDown")) { //TODO: pull reading from a text stream into Roomie.Desktop.Engine.RoomieEngine line = Console.ReadLine().Trim(); if (!String.IsNullOrEmpty(line)) { if (input.Length > 0) { input += "\n"; } input += line.TrimEnd('_'); //TODO: read multiple lines if (!line.EndsWith("_")) { try { var script = ScriptCommandList.FromText(input); engine.Threads.AddCommands(script); Console.WriteLine("Command accepted."); input = ""; } catch (Exception exception) { Console.WriteLine("Error. " + exception.Message); } } } else { if (input != "") { input = ""; Console.WriteLine("Input cleared."); } } } }
public EngineStartup(RoomieEngine engine) { _engine = engine; _threadpool = engine.CreateThreadPool("Startup Threads"); }
internal ThreadPool(RoomieEngine engine, string name) { _engine = engine; _name = name; _threads = new List <RoomieThread>(); }
protected override void OnStart(string[] args) { engine = new RoomieEngine(); engine.Start(); }
public EngineShutdown(RoomieEngine engine) { _engine = engine; _threadpool = _engine.CreateThreadPool("Shutdown Tasks"); }
static void setOutput(RoomieEngine engine) { var streamWriter = new RoomieEventTextStream(engine, Console.Out, new TimeSpan(hours: 0, minutes: 0, seconds: 30)); }
public HomeAutomationNetworkContext(RoomieEngine engine, ThreadPool threadPool) : this(engine, threadPool, new DeviceHistory(), new NetworkHistory()) { }
public SpeechResponder(RoomieEngine engine) { RegisteredCommands = new Dictionary<string, ScriptCommandList>(); _speechRecognizer = new NamedSpeechRecognizer(TimeSpan.FromSeconds(10), "Roomie"); ThreadPool = engine.CreateThreadPool("Speech Recognizer"); }
public EngineShutdown(RoomieEngine engine) { _engine = engine; _threadpool = _engine.CreateThreadPool("Shutdown Tasks"); }
public EngineStartup(RoomieEngine engine) { _engine = engine; _threadpool = engine.CreateThreadPool("Startup Threads"); }