示例#1
0
 /**
  * This callback method is invoked in response to the 'RingerStatusEvent' event.
  * Application will check ring pattern and display the status on the console.
  **/
 public void OnRingerStatusHandler(object sender, RingerStatusEventArgs args)
 {
     if ((RingPattern)args.RingPattern == RingPattern.RingerOff)
     {
         Console.WriteLine("The ringer is off.");
     }
     else
     {
         /*
          * There are a number of different ringing patterns that can indicate that
          * a call has been offered to the destination staition.
          * Print out the pattern and expect  that an interested user
          * will investigate more throughly
          */
         Console.WriteLine("The ringer is ringing in pattern:" + (RingPattern)args.RingPattern);
     }
 }
示例#2
0
        /* 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
            {
            }
        }