public WebHandler(UserHardwareLinker uhl) { //Initializing web server this.http = new HTTPServer(WEB_PORT); this.uhl = uhl; http.OnDataRecived += http_OnDataRecived; http.OnError += http_OnError; Task httpTask = http.Start(); httpTask.Wait(); System.Diagnostics.Debug.WriteLine("web server created"); }
public ConnectionHandler(UserHardwareLinker uhl) { //Initializing socket listener tcp = new TCPListener(SOCKET_PORT, easyDebug); tcp.OnDataReceived += socket_onDataReceived; tcp.OnError += socket_onError; Task SocketListenTask = tcp.ListenAsync(); this.uhl = uhl; SocketListenTask.Wait(); System.Diagnostics.Debug.WriteLine("socket created"); }
public async Task MainPageAsync() { //Initializing GPIO gpioController = GpioController.GetDefault(); if (gpioController != null) { dout = gpioController.OpenPin(DOUT_PIN); clk = gpioController.OpenPin(SLK_PIN); uhl = new UserHardwareLinker(clk, dout); System.Diagnostics.Debug.WriteLine("Connected to Hardware via GPIO."); } else { System.Diagnostics.Debug.WriteLine("WARNING: Your machine does not support GPIO!"); } //Start listening to messages from clients new ConnectionHandler(uhl); //Start Web Server new WebHandler(uhl); //loading permanent data from memory Task loadTask = PermanentData.LoadFromMemoryAsync(); await loadTask; Task putRecordTask = null; PermanentData.CurrIP = GetLocalIp(); if (!PermanentData.Serial.Equals(PermanentData.NULL_SYMBOL)) { putRecordTask = putRecordInDatabase(PermanentData.CurrIP, PermanentData.Serial); } if (uhl != null) { uhl.setParameters(PermanentData.Offset, PermanentData.Scale); } NetworkInformation.NetworkStatusChanged += NetworkInformation_NetworkStatusChanged; if (putRecordTask != null) { await putRecordTask; } }