Exemple #1
0
        /**
         * Handles Contact authorization requests.
         * <ol>
         *   <li>Obtains a list of Contacts awaiting authorization.</li>
         *   <li>Wait for status changes on those Contacts.</li>
         * </ol>
         *
         * @param mySession
         *	Populated session object.
         *
         * @since 1.0
         */
        static void doGetContactRequest(MySession mySession)
        {
            // Here we will get ourselves a ContactGroup object, so that we can get
            // OnChange events when an incoming authorization request occurs.
            ContactGroup waitingForAuthList =
                (ContactGroup)mySession.mySkype.getHardwiredContactGroup(ContactGroup.Type.CONTACTS_WAITING_MY_AUTHORIZATION);

            // The following may look just like a decoration but in fact, you MUST read at least one property
            // of the object (waitingForAuthList) to start getting OnChange events. We'll randomly pick nrofcontacts
            // and ignore its value.
            waitingForAuthList.getContactCount();

            // The rest of the interesting stuff will take place in ContactGroup.OnChange
            MySession.myConsole.printf("%s: Waiting for authorization request events...%nPress Enter to quit.%n%n",
                                       mySession.myTutorialTag);
            try
            {
                while (true)
                {
                    int keyboardChar = (int)System.Console.ReadKey().KeyChar;
                    // Some platforms think ENTER is 0x0D; others think it's 0x0A...
                    if ((keyboardChar == 0x0D) || (keyboardChar == 0x0A))
                    {
                        break;
                    }
                }
            }
            catch (IOException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
                return;
            }

            MySession.myConsole.println();
        }