Exemplo n.º 1
0
        /*
         * This callback method is invoked in response to the 'LampModeEvent'.  This event
         * indicates the status of the lamp display for the application. Call state can be
         * inferred from the lamp state of call appearance buttons.
         *
         * Lamp mode='flash' represents green lamp flashing on the device and indicates an incoming
         *                   call if the button is a call appearance.
         * Lamp mode='steady' represents green lamp is on and not flashing and indicates the
         *                    calll has been established if the button is a call appearance.
         * Lamp mode='off' represents green lamp goes dark and indicates that the call
         *                 has been disconnected if the button is a call appearance.
         * Note that the red lamp (in-use) indicates which call-appearance is selected.
         * The greep lamp indicates the status of the button (call-appearance/feature).
         * Triggering behaviors off the button type and the green lamp state is best.
         *
         */

        public void OnLampModeHandler(object sender, LampModeEventArgs args)
        {
            /*
             * In telecommunter mode the only lamp changes we expect are for a single
             * call appearance button. This application does not check to make sure
             * the changes we are receiving meet these conditions.
             *
             * This function prints the lamp state information and takes no further action.
             */

            // Checking for only Green lamp modes and ignoring the Red lamp modes
            if (args.LampColor == LampColor.Green)
            {
                if (args.LampMode == LampMode.Flashing) // incoming call
                {
                    // A flashing green call appearance lamp indicates that there is an incoming call
                    Console.WriteLine("Lamp " + args.Lamp + " is now flashing.");
                    Console.WriteLine("Receiving an Incoming call");
                }
                else if (args.LampMode == LampMode.Off) // Call disconnected
                {
                    Console.WriteLine("Lamp " + args.Lamp + " is now off.");
                    Console.WriteLine("The call has been disconnected");
                }
                else if (args.LampMode == LampMode.Steady) // Call Connected
                {
                    // A steady green call appearance lamp indicates that the call is now established
                    Console.WriteLine("Lamp " + args.Lamp + " is now on.");
                    Console.WriteLine("The call has been answered");
                }
            }
        }
Exemplo n.º 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
            {
            }
        }