/** * This callback method is invoked in response to the 'DisplayUpdatedEvent'. * This sample application displays the contents of device display on the console. * This handler can be modified to provide more involved display information handling. **/ public void OnDisplayUpdatedHandler(object sender, DisplayUpdatedEventArgs args) { if (args.Message != null) { Console.WriteLine("Display update event: " + args.Message); } }
/* This function is the thread procedure for reader thread. * This reads the responses and appropriately converts them into events. * */ private void HandleReponseThreadProc() { try { while (!StopReadResponse) { /* Ensure there is some data on the stream */ if (socket_handle.NWStream.DataAvailable == false) { System.Threading.Thread.Sleep(1000); continue; } string response = xmlHandler.readXMLMessage(); // parse the response and create a document node tree structure for accessing XML data XmlDocument doc = new XmlDocument(); doc.LoadXml(response); XmlElement root = doc.DocumentElement; Console.WriteLine("Received event : {0}", root.Name); switch (root.Name) { case "LampModeEvent": { LampModeEventArgs lampModeEventArgs = new LampModeEventArgs(root); OnLampModeEvent(this, lampModeEventArgs); break; } case "DisplayUpdatedEvent": { DisplayUpdatedEventArgs displayUpdatedArgs = new DisplayUpdatedEventArgs(root); OnDisplayUpdatedEvent(this, displayUpdatedArgs); break; } case "RingerStatusEvent": { RingerStatusEventArgs ringerStatusEventArgs = new RingerStatusEventArgs(root); OnRingerStatusEvent(this, ringerStatusEventArgs); break; } case "ResetApplicationSessionTimerPosResponse": { Console.WriteLine("ResetApplicationSessionTimerPosResponse received from AE Services server"); break; } case "CSTAException": { XmlNodeList NodeList = root.GetElementsByTagName("message"); Console.WriteLine(NodeList[0].InnerText); } break; case "TerminalUnregisteredEvent": { TerminalUnregisteredEventArgs terminalUnregisteredEventArgs = new TerminalUnregisteredEventArgs(root); OnTerminalUnregisteredEvent(this, terminalUnregisteredEventArgs); break; } default: { Console.WriteLine("Unknown event received from AE Services server: {0}", root.Name); // This application ignores unrecognized events. break; } } // End of switch }// End of while } catch (ThreadAbortException ex) { /* When user presses 'any key' to stop the application, reader thread is aborted to immediately * stop the processing. This results in receiveing ThreadAbortException here. * Do nothing in this exception handler. */ } catch (Exception ex) { ExceptionArgs args = new ExceptionArgs(ex.Message); OnException(this, args); } finally { } }