コード例 #1
0
        public void IfWhereNowIsCalledThenItShouldReturnInfo()
        {
            ThreadPool.QueueUserWorkItem((s) =>
            {
                receivedWhereNowMessage = false;

                Pubnub pubnub           = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
                PubnubUnitTest unitTest = new PubnubUnitTest();
                unitTest.TestClassName  = "WhenAClientIsPresented";
                unitTest.TestCaseName   = "IfWhereNowIsCalledThenItShouldReturnInfo";
                pubnub.PubnubUnitTest   = unitTest;
                string uuid             = customUUID;

                mreWhereNow = new ManualResetEvent(false);
                pubnub.WhereNow <string>(uuid, ThenWhereNowShouldReturnMessage, DummyErrorCallback);
                mreWhereNow.WaitOne(60 * 1000);

                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    Assert.IsTrue(receivedWhereNowMessage, "where_now message not received");
                    pubnub.PubnubUnitTest = null;
                    pubnub = null;
                    TestComplete();
                });
            });
        }
コード例 #2
0
        private void btnWhereNow_Click(object sender, RoutedEventArgs e)
        {
            CheckUserInputs();
            uuid = txtUUID.Text;
            if (uuid.Trim() == "")
            {
                MessageBox.Show("UUID is required");
                return;
            }

            if (authKey.Trim() != "")
            {
                pubnub.AuthenticationKey = authKey;
            }

            WhereNowDialog whereNowPopup = new WhereNowDialog();

            whereNowPopup.txtWhereNowUUID.Text = uuid;

            whereNowPopup.Show();

            whereNowPopup.Closed += (obj, args) =>
            {
                if (whereNowPopup.DialogResult == true && whereNowPopup.txtWhereNowUUID.Text.Length > 0)
                {
                    Console.WriteLine("Running WhereNow()");

                    string whereNowUUID = whereNowPopup.txtWhereNowUUID.Text;
                    pubnub.WhereNow <string>(whereNowUUID, DisplayUserCallbackMessage, DisplayErrorMessage);
                }
            };
        }
コード例 #3
0
        public void IfWhereNowIsCalledThenItShouldReturnInfo()
        {
            mrePresence = new ManualResetEvent(false);
            ThreadPool.QueueUserWorkItem((s) =>
            {
                Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
                string uuid   = customUUID;

                PubnubUnitTest unitTest = new PubnubUnitTest();
                unitTest.TestClassName  = "WhenAClientIsPresented";
                unitTest.TestCaseName   = "IfWhereNowIsCalledThenItShouldReturnInfo";
                pubnub.PubnubUnitTest   = unitTest;

                EnqueueCallback(() => pubnub.WhereNow <string>(uuid, ThenWhereNowShouldReturnMessage, DummyErrorCallback));
                mrePresence.WaitOne(310 * 1000);
                EnqueueCallback(() => Assert.IsTrue(receivedWhereNowMessage, "where_now message not received"));
                EnqueueCallback(() =>
                {
                    pubnub.PubnubUnitTest = null;
                    pubnub = null;
                }
                                );
                EnqueueTestComplete();
            });
        }
コード例 #4
0
        private void btnWhereNow_Click(object sender, RoutedEventArgs e)
        {
            this.IsEnabled = false;
            Border border = new Border();

            border.BorderBrush     = new SolidColorBrush(Colors.Black);
            border.BorderThickness = new Thickness(5.0);

            StackPanel whereNowStackPanel = new StackPanel();

            whereNowStackPanel.Background = new SolidColorBrush(Colors.Blue);
            whereNowStackPanel.Width      = 300;
            whereNowStackPanel.Height     = 300;

            whereNowPopup        = new Popup();
            whereNowPopup.Height = 300;
            whereNowPopup.Width  = 300;

            whereNowPopup.HorizontalOffset = 10;
            whereNowPopup.VerticalOffset   = 100;

            WhereNowUserControl control         = new WhereNowUserControl();
            TextBox             txtWhereNowUUID = control.FindName("txtWhereNowUUID") as TextBox;

            if (txtWhereNowUUID != null)
            {
                txtWhereNowUUID.Text = data.sessionUUID;
            }

            whereNowStackPanel.Children.Add(control);
            border.Child = whereNowStackPanel;

            whereNowPopup.Child  = border;
            whereNowPopup.IsOpen = true;

            whereNowPopup.Closed += (senderPopup, argsPopup) =>
            {
                if (control.IsOKButtonEntered)
                {
                    TextBox txtWhereNowUUIDConfirm = control.FindName("txtWhereNowUUID") as TextBox;
                    if (txtWhereNowUUIDConfirm != null)
                    {
                        string whereNowUUID = txtWhereNowUUIDConfirm.Text.Trim();

                        DisplayMessageInTextBox("Running WhereNow:");

                        pubnub.WhereNow()
                        .Uuid(whereNowUUID)
                        .Async(new PNWhereNowResultExt((r, s) =>
                        {
                            DisplayMessageInTextBox(pubnub.JsonPluggableLibrary.SerializeToJsonString(r));
                        }));
                    }
                }
                whereNowPopup  = null;
                this.IsEnabled = true;
            };
        }
コード例 #5
0
        private void btnWhereNow_Click(object sender, RoutedEventArgs e)
        {
            this.IsEnabled = false;
            Border border = new Border();

            border.BorderBrush     = new SolidColorBrush(Colors.Black);
            border.BorderThickness = new Thickness(5.0);

            StackPanel whereNowStackPanel = new StackPanel();

            whereNowStackPanel.Background = new SolidColorBrush(Colors.Blue);
            whereNowStackPanel.Width      = 300;
            whereNowStackPanel.Height     = 300;

            whereNowPopup        = new Popup();
            whereNowPopup.Height = 300;
            whereNowPopup.Width  = 300;

            var point = CalcOffsets((UIElement)sender);

            whereNowPopup.HorizontalOffset = point.X + 70;
            whereNowPopup.VerticalOffset   = point.Y - 100;

            WhereNowUserControl control         = new WhereNowUserControl();
            TextBox             txtWhereNowUUID = control.FindName("txtWhereNowUUID") as TextBox;

            if (txtWhereNowUUID != null)
            {
                txtWhereNowUUID.Text = data.sessionUUID;
            }

            whereNowStackPanel.Children.Add(control);
            border.Child = whereNowStackPanel;

            whereNowPopup.Child  = border;
            whereNowPopup.IsOpen = true;

            whereNowPopup.Closed += (senderPopup, argsPopup) =>
            {
                if (control.IsOKButtonEntered)
                {
                    TextBox txtWhereNowUUIDConfirm = control.FindName("txtWhereNowUUID") as TextBox;
                    if (txtWhereNowUUIDConfirm != null)
                    {
                        string whereNowUUID = txtWhereNowUUIDConfirm.Text.Trim();

                        DisplayMessageInTextBox("Running WhereNow:");
                        pubnub.WhereNow <string>(whereNowUUID, PubnubCallbackResult, PubnubDisplayErrorMessage);
                    }
                }
                whereNowPopup  = null;
                this.IsEnabled = true;
            };
        }
コード例 #6
0
        public void IfWhereNowIsCalledThenItShouldReturnInfo()
        {
            receivedWhereNowMessage = false;

            Pubnub         pubnub   = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenAClientIsPresented";
            unitTest.TestCaseName  = "IfWhereNowIsCalledThenItShouldReturnInfo";
            pubnub.PubnubUnitTest  = unitTest;
            string uuid = "hello_my_uuid";

            pubnub.WhereNow <string>(uuid, ThenWhereNowShouldReturnMessage, DummyErrorCallback);
            whereNowManualEvent.WaitOne();
            Assert.IsTrue(receivedWhereNowMessage, "where_now message not received");
        }
コード例 #7
0
        public void TestWhereNow()
        {
            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                false
                );
            Common common = new Common();

            common.DeliveryStatus = false;
            common.Response       = null;

            string channel  = "testChannel7";
            string testname = "IfHereNowIsCalledWithState";

            Common commonSubscribe = new Common();

            pubnub.Subscribe <string> (channel, commonSubscribe.DisplayReturnMessage, commonSubscribe.DisplayReturnMessage, commonSubscribe.DisplayErrorMessage);
            commonSubscribe.WaitForResponse();

            Thread.Sleep(5000);

            pubnub.WhereNow <string> ("", common.DisplayReturnMessage, common.DisplayErrorMessage);
            common.WaitForResponse();

            if (common.Response.Equals(null))
            {
                Assert.Fail("Null response");
            }
            else
            {
                if (common.Response.ToString().Contains(pubnub.SessionUUID) &&
                    common.Response.ToString().Contains(channel))
                {
                    Assert.True(true, "Test passed:" + testname);
                }
                else
                {
                    Console.WriteLine("response:" + common.Response.ToString());
                    Assert.Fail("Test failed:" + testname);
                }
            }
            pubnub.Unsubscribe <string> (channel, commonSubscribe.DisplayReturnMessageDummy, commonSubscribe.DisplayReturnMessageDummy, commonSubscribe.DisplayReturnMessageDummy, commonSubscribe.DisplayReturnMessageDummy);
            pubnub.EndPendingRequests();
        }
コード例 #8
0
        private void btnWhereNow_Click(object sender, RoutedEventArgs e)
        {
            this.IsEnabled = false;
            Border border = new Border();

            border.BorderBrush     = new SolidColorBrush(Colors.Black);
            border.BorderThickness = new Thickness(5.0);

            StackPanel whereNowStackPanel = new StackPanel();

            whereNowStackPanel.Background = new SolidColorBrush(Colors.Blue);
            whereNowStackPanel.Width      = 300;
            whereNowStackPanel.Height     = 300;

            whereNowPopup                  = new Popup();
            whereNowPopup.Height           = 300;
            whereNowPopup.Width            = 300;
            whereNowPopup.VerticalOffset   = 100;
            whereNowPopup.HorizontalOffset = 100;
            WhereNowUserControl control = new WhereNowUserControl();

            control.txtWhereNowUUID.Text = uuid;
            whereNowStackPanel.Children.Add(control);
            border.Child = whereNowStackPanel;

            whereNowPopup.Child  = border;
            whereNowPopup.IsOpen = true;
            control.btnOK.Click += (s, args) =>
            {
                whereNowPopup.IsOpen = false;
                string whereNowUUID = control.txtWhereNowUUID.Text;
                pubnub.WhereNow <string>(whereNowUUID, PubnubCallbackResult, PubnubDisplayErrorMessage);
                TextBlock textBlock = new TextBlock();
                textBlock.Text = string.Format("Running WhereNow \n");
                messageStackPanel.Children.Add(textBlock);
                scrollViewerResult.UpdateLayout();
                scrollViewerResult.ScrollToVerticalOffset(scrollViewerResult.ExtentHeight);
                whereNowPopup  = null;
                this.IsEnabled = true;
            };
            control.btnCancel.Click += (s, args) =>
            {
                whereNowPopup.IsOpen = false;
                whereNowPopup        = null;
                this.IsEnabled       = true;
            };
        }
コード例 #9
0
        public void IfWhereNowIsCalledThenItShouldReturnInfo()
        {
            mrePresence = new ManualResetEvent(false);
            ThreadPool.QueueUserWorkItem((s) =>
                {
                    Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
                    string uuid = "hello_my_uuid";

                    PubnubUnitTest unitTest = new PubnubUnitTest();
                    unitTest.TestClassName = "WhenAClientIsPresented";
                    unitTest.TestCaseName = "IfWhereNowIsCalledThenItShouldReturnInfo";
                    pubnub.PubnubUnitTest = unitTest;

                    EnqueueCallback(() => pubnub.WhereNow<string>(uuid, ThenWhereNowShouldReturnMessage, DummyErrorCallback));
                    mrePresence.WaitOne(310 * 1000);
                    EnqueueCallback(() => Assert.IsTrue(receivedWhereNowMessage, "where_now message not received"));
                    EnqueueTestComplete();
                });
        }
コード例 #10
0
        void ProcessPubnubRequest(string requestType)
        {
            CheckUserInputs();
            channel = txtChannel.Text;
            string messageToBePublished = txtPublishMessage.Text;
            bool   storeInHistory       = chkStoreInHistory.Checked;
            string pamAuthKey           = txtPAMAuthKey.Text.Trim();

            UpdateTimer.Enabled = true;

            switch (requestType.ToLower())
            {
            case "presence":
                pubnub.Presence <string>(channel, DisplayUserCallbackMessage, DisplayConnectCallbackMessage, DisplayErrorMessage);
                break;

            case "subscribe":
                pubnub.Subscribe <string>(channel, DisplayUserCallbackMessage, DisplayConnectCallbackMessage, DisplayErrorMessage);
                break;

            case "detailedhistory":
                pubnub.DetailedHistory <string>(channel, 10, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "publish":
                pubnub.Publish <string>(channel, messageToBePublished, storeInHistory, DisplayUserCallbackMessage, DisplayErrorMessage);
                txtPublishMessage.Text = "";
                lblErrorMessage.Text   = "";
                break;

            case "unsubscribe":
                pubnub.Unsubscribe <string>(channel, DisplayUserCallbackMessage, DisplayConnectCallbackMessage, DisplayDisconnectCallbackMessage, DisplayErrorMessage);
                break;

            case "presenceunsubscribe":
                pubnub.PresenceUnsubscribe <string>(channel, DisplayUserCallbackMessage, DisplayConnectCallbackMessage, DisplayDisconnectCallbackMessage, DisplayErrorMessage);
                break;

            case "herenow":
                bool showUUID2         = chbShowUUIDList2.Checked;
                bool includeUserState2 = chbShowUserState2.Checked;
                pubnub.HereNow <string>(channel, showUUID2, includeUserState2, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "globalherenow":
                bool showUUID         = chbShowUUIDList.Checked;
                bool includeUserState = chbShowUserState.Checked;
                pubnub.GlobalHereNow <string>(showUUID, includeUserState, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "wherenow":
                pubnub.WhereNow <string>(uuid, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "time":
                pubnub.Time <string>(DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "grantaccess":
                pubnub.GrantAccess <string>(channel, pamAuthKey, true, true, 60, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "revokeaccess":
                pubnub.GrantAccess <string>(channel, pamAuthKey, false, false, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "auditaccess":
                pubnub.AuditAccess <string>(channel, pamAuthKey, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "disablenetwork":
                pubnub.EnableSimulateNetworkFailForTestingOnly();
                break;

            case "enablenetwork":
                pubnub.DisableSimulateNetworkFailForTestingOnly();
                break;

            case "disconnectandretry":
                pubnub.TerminateCurrentSubscriberRequest();
                break;

            case "getuserstate":
                string getUserStateUUID = txtGetUserStateUUID.Text;
                pubnub.GetUserState <string>(channel, getUserStateUUID, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "jsonsetuserstate":
                string jsonUserState = txtJsonUserState.Text;
                pubnub.SetUserState <string>(channel, jsonUserState, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "setuserstate":
                string key1   = txtKey1.Text;
                string value1 = txtValue1.Text;

                int    valueInt;
                double valueDouble;

                if (Int32.TryParse(value1, out valueInt))
                {
                    pubnub.SetUserState <string>(channel, new KeyValuePair <string, object>(key1, valueInt), DisplayUserCallbackMessage, DisplayErrorMessage);
                }
                else if (Double.TryParse(value1, out valueDouble))
                {
                    pubnub.SetUserState <string>(channel, new KeyValuePair <string, object>(key1, valueDouble), DisplayUserCallbackMessage, DisplayErrorMessage);
                }
                else
                {
                    pubnub.SetUserState <string>(channel, new KeyValuePair <string, object>(key1, value1), DisplayUserCallbackMessage, DisplayErrorMessage);
                }

                break;

            default:
                break;
            }
        }
コード例 #11
0
        void HandleSetValues(object sender, EventArgs ea)
        {
            try {
                SetEventArgs cea = ea as SetEventArgs;

                if (cea.cds == CommonDialogStates.Auth)
                {
                    Display("Setting Auth Key");
                    pubnub.AuthenticationKey = cea.valueToSet;
                    Display("Auth Key set");
                }
                else if (cea.cds == CommonDialogStates.AuditSubscribe)
                {
                    Display("Running Channel Subscribe Audit");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.AuditAccess <string> (cea.channel, cea.valueToSet, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.AuditPresence)
                {
                    Display("Running Presence Audit");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.AuditPresenceAccess <string> (cea.channel, cea.valueToSet, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.AuditChannelGroupSubscribe)
                {
                    Display("Running ChannelGroup Subscribe Audit");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.ChannelGroupAuditAccess <string> (cea.channelGroup, cea.valueToSet, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.AuditChannelGroupPresence)
                {
                    Display("Running ChannelGroup Presence Audit");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.ChannelGroupAuditPresenceAccess <string> (cea.channelGroup, cea.valueToSet, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.RevokePresence)
                {
                    Display("Running Presence Revoke");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.GrantPresenceAccess <string> (cea.channel, cea.valueToSet, false, false, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.RevokeSubscribe)
                {
                    Display("Running Subscribe Revoke");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.GrantAccess <string> (cea.channel, cea.valueToSet, false, false, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.RevokeChannelGroupPresence)
                {
                    Display("Running ChannelGroup Presence Revoke");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.ChannelGroupGrantPresenceAccess <string> (cea.channelGroup, cea.valueToSet, false, false, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.RevokeChannelGroupSubscribe)
                {
                    Display("Running ChannelGroup Revoke");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.ChannelGroupGrantAccess <string> (cea.channelGroup, cea.valueToSet, false, false, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.ChangeUuid)
                {
                    Display("Setting UUID");
                    pubnub.ChangeUUID(cea.valueToSet);
                    Display(string.Format("UUID set to {0}", pubnub.SessionUUID));
                }
                else if (cea.cds == CommonDialogStates.WhereNow)
                {
                    Display("Running where now");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.WhereNow <string> (cea.valueToSet, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.GetUserState)
                {
                    Display("Running get user state");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.GetUserState <string> (cea.channel, cea.channelGroup, cea.valueToSet, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.DeleteUserState)
                {
                    Display("Running delete user state");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.SetUserState <string> (cea.channel, cea.channelGroup, new KeyValuePair <string, object> (cea.valueToSet, null), DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.PresenceHeartbeat)
                {
                    Display("Setting presence heartbeat");
                    //int check done in CommonDialogFragment
                    pubnub.PresenceHeartbeat = int.Parse(cea.valueToSet);

                    Display(string.Format("PresenceHeartbeat set to {0}", pubnub.PresenceHeartbeat));
                }
                else if (cea.cds == CommonDialogStates.PresenceHeartbeatInterval)
                {
                    Display("Setting presence interval");
                    //int check done in CommonDialogFragment
                    pubnub.PresenceHeartbeatInterval = int.Parse(cea.valueToSet);
                    Display(string.Format("PresenceHeartbeatInterval set to {0}", pubnub.PresenceHeartbeatInterval));
                }
                else if (cea.cds == CommonDialogStates.AddUserStateKeyValue)
                {
                    int    valueInt;
                    double valueDouble;

                    if (Int32.TryParse(cea.valueToSet2, out valueInt))
                    {
                        ThreadPool.QueueUserWorkItem(o =>
                                                     pubnub.SetUserState <string> (cea.channel, cea.channelGroup, new KeyValuePair <string, object> (cea.valueToSet, valueInt), DisplayReturnMessage, DisplayErrorMessage)
                                                     );
                    }
                    else if (Double.TryParse(cea.valueToSet2, out valueDouble))
                    {
                        ThreadPool.QueueUserWorkItem(o =>
                                                     pubnub.SetUserState <string> (cea.channel, cea.channelGroup, new KeyValuePair <string, object> (cea.valueToSet, valueDouble), DisplayReturnMessage, DisplayErrorMessage)
                                                     );
                    }
                    else
                    {
                        ThreadPool.QueueUserWorkItem(o =>
                                                     pubnub.SetUserState <string> (cea.channel, cea.channelGroup, new KeyValuePair <string, object> (cea.valueToSet, cea.valueToSet2), DisplayReturnMessage, DisplayErrorMessage)
                                                     );
                    }
                }
                else if (cea.cds == CommonDialogStates.SetUserStateJson)
                {
                    string jsonUserState = "";
                    if (string.IsNullOrEmpty(cea.valueToSet2))
                    {
                        //jsonUserState = ;
                    }
                    else
                    {
                        jsonUserState = cea.valueToSet2;
                    }
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.SetUserState <string> (cea.channel, cea.channelGroup, cea.valueToSet, jsonUserState, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
            } catch (Exception ex) {
                Display(ex.Message);
            } finally {
                CommonDialogFragment coroutine = sender as CommonDialogFragment;
                coroutine.SetValues -= HandleSetValues;
            }
        }
コード例 #12
0
		static public void Main ()
		{
			AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper;

			PubnubProxy proxy = null;
            
			Console.WriteLine ("HINT: TO TEST RE-CONNECT AND CATCH-UP,");
			Console.WriteLine ("      DISCONNECT YOUR MACHINE FROM NETWORK/INTERNET AND ");
			Console.WriteLine ("      RE-CONNECT YOUR MACHINE AFTER SOMETIME.");
			Console.WriteLine ();
			Console.WriteLine ("      IF NO NETWORK BEFORE MAX RE-TRY CONNECT,");
			Console.WriteLine ("      NETWORK ERROR MESSAGE WILL BE SENT");
			Console.WriteLine ();

			Console.WriteLine ("Enter Pubnub Origin. Default Origin = pubsub.pubnub.com");
			Console.WriteLine ("If you want to accept default value, press ENTER.");
			string origin = Console.ReadLine ();
			Console.ForegroundColor = ConsoleColor.Blue;
			if (origin.Trim () == "") {
				origin = "pubsub.pubnub.com";
				Console.WriteLine ("Default Origin selected");
			} else {
				Console.WriteLine ("Pubnub Origin Provided");
			}
			Console.ResetColor ();
			Console.WriteLine ();

			Console.WriteLine ("Enable SSL? ENTER Y for Yes, else N");
			string enableSSL = Console.ReadLine ();
			Console.ForegroundColor = ConsoleColor.Blue;
			if (enableSSL.Trim ().ToLower () == "y") {
				Console.WriteLine ("SSL Enabled");
			} else {
				Console.WriteLine ("SSL NOT Enabled");
			}
			Console.ResetColor ();
			Console.WriteLine ();

			Console.WriteLine ("ENTER cipher key for encryption feature.");
			Console.WriteLine ("If you don't want to avail at this time, press ENTER.");
			string cipherKey = Console.ReadLine ();
			Console.ForegroundColor = ConsoleColor.Blue;
			if (cipherKey.Trim ().Length > 0) {
				Console.WriteLine ("Cipher key provided.");
			} else {
				Console.WriteLine ("No Cipher key provided");
			}
			Console.ResetColor ();
			Console.WriteLine ();

			Console.WriteLine ("ENTER subscribe key.");
			Console.WriteLine ("If you want to accept default demo subscribe key, press ENTER.");
			string subscribeKey = Console.ReadLine ();
			Console.ForegroundColor = ConsoleColor.Blue;
			if (subscribeKey.Trim ().Length > 0) {
				Console.WriteLine ("Subscribe key provided.");
			} else {
				Console.WriteLine ("Default demo subscribe key provided");
				subscribeKey = "demo-36";
			}
			Console.ResetColor ();
			Console.WriteLine ();

			Console.WriteLine ("ENTER publish key.");
			Console.WriteLine ("If you want to accept default demo publish key, press ENTER.");
			string publishKey = Console.ReadLine ();
			Console.ForegroundColor = ConsoleColor.Blue;
			if (publishKey.Trim ().Length > 0) {
				Console.WriteLine ("Publish key provided.");
			} else {
				Console.WriteLine ("Default demo publish key provided");
				publishKey = "demo-36";
			}
			Console.ResetColor ();
			Console.WriteLine ();

			Console.WriteLine ("ENTER secret key.");
			Console.WriteLine ("If you don't want to avail at this time, press ENTER.");
			string secretKey = Console.ReadLine ();
			Console.ForegroundColor = ConsoleColor.Blue;
			if (secretKey.Trim ().Length > 0) {
				Console.WriteLine ("Secret key provided.");
			} else {
				Console.WriteLine ("Default demo secret key provided");
				secretKey = "demo-36";
			}
			Console.ResetColor ();
			Console.WriteLine ();

			pubnub = new Pubnub (publishKey, subscribeKey, secretKey, cipherKey,
				(enableSSL.Trim ().ToLower () == "y") ? true : false);
			pubnub.Origin = origin;

			Console.WriteLine ("Use Custom Session UUID? ENTER Y for Yes, else N");
			string enableCustomUUID = Console.ReadLine ();
			if (enableCustomUUID.Trim ().ToLower () == "y") {
				Console.WriteLine ("ENTER Session UUID.");
				string sessionUUID = Console.ReadLine ();
				pubnub.SessionUUID = sessionUUID;
				Console.ForegroundColor = ConsoleColor.Blue;
				Console.WriteLine ("Accepted Custom Session UUID.");
				Console.ResetColor ();
			} else {
				Console.ForegroundColor = ConsoleColor.Blue;
				Console.WriteLine ("Default Session UUID opted.");
				Console.ResetColor ();
			}
			Console.WriteLine ();

			Console.WriteLine ("By default Resume On Reconnect is enabled. Do you want to disable it? ENTER Y for Yes, else N");
			string disableResumeOnReconnect = Console.ReadLine ();
			Console.ForegroundColor = ConsoleColor.Blue;
			if (disableResumeOnReconnect.Trim ().ToLower () == "y") {
				Console.WriteLine ("Resume On Reconnect Disabled");
				pubnub.EnableResumeOnReconnect = false;
			} else {
				Console.WriteLine ("Resume On Reconnect Enabled by default");
				pubnub.EnableResumeOnReconnect = true;
			}
			Console.ResetColor ();
			Console.WriteLine ();

			Console.WriteLine ("Subscribe Timeout = 310 seconds (default). Enter the value to change, else press ENTER");
			string subscribeTimeoutEntry = Console.ReadLine ();
			int subscribeTimeout;
			Int32.TryParse (subscribeTimeoutEntry, out subscribeTimeout);
			Console.ForegroundColor = ConsoleColor.Blue;
			if (subscribeTimeout > 0) {
				Console.WriteLine ("Subscribe Timeout = {0}", subscribeTimeout);
				pubnub.SubscribeTimeout = subscribeTimeout;
			} else {
				Console.WriteLine ("Subscribe Timeout = {0} (default)", pubnub.SubscribeTimeout);
			}
			Console.ResetColor ();
			Console.WriteLine ();

			Console.WriteLine ("Non Subscribe Timeout = 15 seconds (default). Enter the value to change, else press ENTER");
			string nonSubscribeTimeoutEntry = Console.ReadLine ();
			int nonSubscribeTimeout;
			Int32.TryParse (nonSubscribeTimeoutEntry, out nonSubscribeTimeout);
			Console.ForegroundColor = ConsoleColor.Blue;
			if (nonSubscribeTimeout > 0) {
				Console.WriteLine ("Non Subscribe Timeout = {0}", nonSubscribeTimeout);
				pubnub.NonSubscribeTimeout = nonSubscribeTimeout;
			} else {
				Console.WriteLine ("Non Subscribe Timeout = {0} (default)", pubnub.NonSubscribeTimeout);
			}
			Console.ResetColor ();
			Console.WriteLine ();

			Console.WriteLine ("Network Check MAX retries = 50 (default). Enter the value to change, else press ENTER");
			string networkCheckMaxRetriesEntry = Console.ReadLine ();
			int networkCheckMaxRetries;
			Int32.TryParse (networkCheckMaxRetriesEntry, out networkCheckMaxRetries);
			Console.ForegroundColor = ConsoleColor.Blue;
			if (networkCheckMaxRetries > 0) {
				Console.WriteLine ("Network Check MAX retries = {0}", networkCheckMaxRetries);
				pubnub.NetworkCheckMaxRetries = networkCheckMaxRetries;
			} else {
				Console.WriteLine ("Network Check MAX retries = {0} (default)", pubnub.NetworkCheckMaxRetries);
			}
			Console.ResetColor ();
			Console.WriteLine ();

			Console.WriteLine ("Network Check Retry Interval = 10 seconds (default). Enter the value to change, else press ENTER");
			string networkCheckRetryIntervalEntry = Console.ReadLine ();
			int networkCheckRetryInterval;
			Int32.TryParse (networkCheckRetryIntervalEntry, out networkCheckRetryInterval);
			Console.ForegroundColor = ConsoleColor.Blue;
			if (networkCheckRetryInterval > 0) {
				Console.WriteLine ("Network Check Retry Interval = {0} seconds", networkCheckRetryInterval);
				pubnub.NetworkCheckRetryInterval = networkCheckRetryInterval;
			} else {
				Console.WriteLine ("Network Check Retry Interval = {0} seconds (default)", pubnub.NetworkCheckRetryInterval);
			}
			Console.ResetColor ();
			Console.WriteLine ();

			Console.WriteLine ("Local Client Heartbeat Interval = 15 seconds (default). Enter the value to change, else press ENTER");
			string heartbeatIntervalEntry = Console.ReadLine ();
			int localClientHeartbeatInterval;
			Int32.TryParse (heartbeatIntervalEntry, out localClientHeartbeatInterval);
			Console.ForegroundColor = ConsoleColor.Blue;
			if (localClientHeartbeatInterval > 0) {
				Console.WriteLine ("Heartbeat Interval = {0} seconds", localClientHeartbeatInterval);
				pubnub.LocalClientHeartbeatInterval = localClientHeartbeatInterval;
			} else {
				Console.WriteLine ("Heartbeat Interval = {0} seconds (default)", pubnub.LocalClientHeartbeatInterval);
			}
			Console.ResetColor ();
			Console.WriteLine ();

			Console.WriteLine ("HTTP Proxy Server with NTLM authentication(IP + username/pwd) exists? ENTER Y for Yes, else N");
			Console.ForegroundColor = ConsoleColor.Red;
			Console.ResetColor ();
			string enableProxy = Console.ReadLine ();
			if (enableProxy.Trim ().ToLower () == "y") {
				bool proxyAccepted = false;
				while (!proxyAccepted) {
					Console.WriteLine ("ENTER proxy server name or IP.");
					string proxyServer = Console.ReadLine ();
					Console.WriteLine ("ENTER port number of proxy server.");
					string proxyPort = Console.ReadLine ();
					int port;
					Int32.TryParse (proxyPort, out port);
					Console.WriteLine ("ENTER user name for proxy server authentication.");
					string proxyUsername = Console.ReadLine ();
					Console.WriteLine ("ENTER password for proxy server authentication.");
					string proxyPassword = Console.ReadLine ();
                    
					proxy = new PubnubProxy ();
					proxy.ProxyServer = proxyServer;
					proxy.ProxyPort = port;
					proxy.ProxyUserName = proxyUsername;
					proxy.ProxyPassword = proxyPassword;
					Console.ForegroundColor = ConsoleColor.Blue;
					try {
						pubnub.Proxy = proxy;
						proxyAccepted = true;
						Console.WriteLine ("Proxy details accepted");
						Console.ResetColor ();
					} catch (MissingFieldException mse) {
						Console.WriteLine (mse.Message);
						Console.WriteLine ("Please RE-ENTER Proxy Server details.");
					}
					Console.ResetColor ();
				}
			} else {
				Console.ForegroundColor = ConsoleColor.Blue;
				Console.WriteLine ("No Proxy");
				Console.ResetColor ();
			}
			Console.WriteLine ();

			Console.WriteLine ("Enter Auth Key. If you don't want to use Auth Key, Press ENTER Key");
			authKey = Console.ReadLine ();
			pubnub.AuthenticationKey = authKey;

			Console.ForegroundColor = ConsoleColor.Blue;
			Console.WriteLine (string.Format ("Auth Key = {0}", pubnub.AuthenticationKey));
			Console.ResetColor ();
			Console.WriteLine ();

			Console.WriteLine ("Display ErrorCallback messages? Enter Y for Yes, Else N for No.");
			Console.WriteLine ("Default = N  ");
			string displayErrMessage = Console.ReadLine ();
			Console.ForegroundColor = ConsoleColor.Blue;
			if (displayErrMessage.Trim ().ToLower () == "y") {
				showErrorMessageSegments = true;
				Console.WriteLine ("ErrorCallback messages will  be displayed");
			} else {
				showErrorMessageSegments = false;
				Console.WriteLine ("ErrorCallback messages will NOT be displayed.");
			}
			Console.ResetColor ();
			Console.WriteLine ();

			Console.WriteLine ("Display Debug Info in ErrorCallback messages? Enter Y for Yes, Else N for No.");
			Console.WriteLine ("Default = Y  ");
			string debugMessage = Console.ReadLine ();
			Console.ForegroundColor = ConsoleColor.Blue;
			if (debugMessage.Trim ().ToLower () == "n") {
				showDebugMessages = false;
				Console.WriteLine ("ErrorCallback messages will NOT  be displayed");
			} else {
				showDebugMessages = true;
				Console.WriteLine ("Debug messages will be displayed.");
			}
			Console.ResetColor ();
			Console.WriteLine ();

			bool exitFlag = false;
			string channel = "";
			int currentUserChoice = 0;
			string userinput = "";
			Console.WriteLine ("");
			while (!exitFlag) {

				if (currentUserChoice < 1 || (currentUserChoice > 30 && currentUserChoice != 99)) {
					Console.WriteLine ("ENTER 1 FOR Subscribe");
					Console.WriteLine ("ENTER 2 FOR Publish");
					Console.WriteLine ("ENTER 3 FOR Presence");
					Console.WriteLine ("ENTER 4 FOR Detailed History");
					Console.WriteLine ("ENTER 5 FOR Here_Now");
					Console.WriteLine ("ENTER 6 FOR Unsubscribe");
					Console.WriteLine ("ENTER 7 FOR Presence-Unsubscribe");
					Console.WriteLine ("ENTER 8 FOR Time");
					Console.WriteLine ("ENTER 9 FOR Disconnect/Reconnect existing Subscriber(s) (when internet is available)");
					Console.WriteLine ("ENTER 10 TO Disable Network Connection (no internet)");
					Console.WriteLine ("ENTER 11 TO Enable Network Connection (yes internet)");
					Console.WriteLine ("ENTER 12 FOR Grant Access");
					Console.WriteLine ("ENTER 13 FOR Audit Access");
					Console.WriteLine ("ENTER 14 FOR Revoke Access");
					Console.WriteLine ("ENTER 15 FOR Grant Access for Presence Channel");
					Console.WriteLine ("ENTER 16 FOR Audit Access for Presence Channel");
					Console.WriteLine ("ENTER 17 FOR Revoke Access for Presence Channel");
					Console.WriteLine ("ENTER 18 FOR Change/Update Auth Key (Current value = {0})", pubnub.AuthenticationKey);
					Console.WriteLine ("ENTER 19 TO Simulate Machine Sleep Mode");
					Console.WriteLine ("ENTER 20 TO Simulate Machine Awake Mode");
					Console.WriteLine ("ENTER 21 TO Set Presence Heartbeat (Current value = {0} sec)", pubnub.PresenceHeartbeat);
					Console.WriteLine ("ENTER 22 TO Set Presence Heartbeat Interval (Current value = {0} sec)", pubnub.PresenceHeartbeatInterval);
					Console.WriteLine ("Enter 23 TO Add/Modify Local User State");
					Console.WriteLine ("Enter 24 TO Delete Local User State");
					Console.WriteLine ("Enter 25 TO View/Get Local User State");
					Console.WriteLine ("Enter 26 TO Set User State");
					Console.WriteLine ("Enter 27 TO Get User State");
					Console.WriteLine ("Enter 28 FOR WhereNow");
					Console.WriteLine ("Enter 29 FOR GlobalHere_Now");
					Console.WriteLine ("Enter 30 TO change UUID. (Current value = {0})", pubnub.SessionUUID);
					Console.WriteLine ("ENTER 99 FOR EXIT OR QUIT");

					userinput = Console.ReadLine ();
				}
				switch (userinput) {
				case "99":
					exitFlag = true;
					pubnub.EndPendingRequests ();
					break;
				case "1":
					Console.WriteLine ("Enter CHANNEL name for subscribe. Use comma to enter multiple channels.");
					channel = Console.ReadLine ();

					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Channel = {0}", channel));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Running subscribe()");
					pubnub.Subscribe<string> (channel, DisplaySubscribeReturnMessage, DisplaySubscribeConnectStatusMessage, DisplayErrorMessage);
                    //pubnub2.Subscribe<string>(channel, DisplaySubscribeReturnMessage, DisplaySubscribeConnectStatusMessage, DisplayErrorMessage);
                    //pubnub.Subscribe<object>(channel, (object o)=> {DisplayReturnMessage(o);}, (object o)=> {DisplayReturnMessage(o);}, DisplayErrorMessage);

					break;
				case "2":
					Console.WriteLine ("Enter CHANNEL name for publish.");
					channel = Console.ReadLine ();

					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Channel = {0}", channel));
					Console.ResetColor ();

                        /* TO TEST SMALL TEXT PUBLISH ONLY */
					Console.WriteLine ("Enter the message for publish and press ENTER key to submit");
					string publishMsg = Console.ReadLine ();

                            /* UNCOMMENT THE FOLLOWING CODE BLOCK TO TEST LARGE TEXT PUBLISH ONLY */
                            #region Code To Test Large Text Publish
                        /*ConsoleKeyInfo enteredKey;
                        StringBuilder publishBuilder = new StringBuilder ();
                        do {
                            enteredKey = Console.ReadKey (); //This logic is being used to capture > 2K input in console window
                            if (enteredKey.Key != ConsoleKey.Enter) {
                                publishBuilder.Append (enteredKey.KeyChar);
                            }
                        } while (enteredKey.Key != ConsoleKey.Enter);
                        string publishMsg = publishBuilder.ToString ();*/
                            #endregion

					Console.WriteLine ("Running publish()");
					Console.WriteLine ("Sending message " + publishMsg);
					double doubleData;
					int intData;
					if (int.TryParse (publishMsg, out intData)) { //capture numeric data
						pubnub.Publish<string> (channel, intData, DisplayReturnMessage, DisplayErrorMessage);
					} else if (double.TryParse (publishMsg, out doubleData)) { //capture numeric data
						pubnub.Publish<string> (channel, doubleData, DisplayReturnMessage, DisplayErrorMessage);
					} else {
						//check whether any numeric is sent in double quotes
						if (publishMsg.IndexOf ("\"") == 0 && publishMsg.LastIndexOf ("\"") == publishMsg.Length - 1) {
							string strMsg = publishMsg.Substring (1, publishMsg.Length - 2);
							if (int.TryParse (strMsg, out intData)) {
								pubnub.Publish<string> (channel, strMsg, DisplayReturnMessage, DisplayErrorMessage);
							} else if (double.TryParse (strMsg, out doubleData)) {
								pubnub.Publish<string> (channel, strMsg, DisplayReturnMessage, DisplayErrorMessage);
							} else {
								pubnub.Publish<string> (channel, publishMsg, DisplayReturnMessage, DisplayErrorMessage);
							}
						} else {
							pubnub.Publish<string> (channel, publishMsg, DisplayReturnMessage, DisplayErrorMessage);
							//pubnub2.Publish<string>(channel, publishMsg, DisplayReturnMessage, DisplayErrorMessage);
						}
					}
					break;
				case "3":
					Console.WriteLine ("Enter CHANNEL name for presence. Use comma to enter multiple channels.");
					channel = Console.ReadLine ();

					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Presence Channel = {0}", channel));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Running presence()");
					pubnub.Presence<string> (channel, DisplayPresenceReturnMessage, DisplayPresenceConnectStatusMessage, DisplayErrorMessage);

					break;
				case "4":
					Console.WriteLine ("Enter CHANNEL name for Detailed History");
					channel = Console.ReadLine ();

					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Channel = {0}", channel));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Running detailed history()");
					pubnub.DetailedHistory<string> (channel, 100, DisplayReturnMessage, DisplayErrorMessage);
					break;
				case "5":
					bool showUUID = true;
					bool includeUserState = false;

					Console.WriteLine ("Enter CHANNEL name for HereNow");
					channel = Console.ReadLine ();

					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Channel = {0}", channel));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Show UUID List? Y or N? Default is Y. Press N for No Else press ENTER");
					string userChoiceShowUUID = Console.ReadLine ();
					if (userChoiceShowUUID.ToLower () == "n") {
						showUUID = false;
					}
					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Show UUID = {0}", showUUID));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Include User State? Y or N? Default is N. Press Y for Yes Else press ENTER");
					string userChoiceIncludeUserState = Console.ReadLine ();
					if (userChoiceIncludeUserState.ToLower () == "y") {
						includeUserState = true;
					}
					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Include User State = {0}", includeUserState));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Running Here_Now()");
					pubnub.HereNow<string> (channel, showUUID, includeUserState, DisplayReturnMessage, DisplayErrorMessage);
					break;
				case "6":
					Console.WriteLine ("Enter CHANNEL name for Unsubscribe. Use comma to enter multiple channels.");
					channel = Console.ReadLine ();

					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Channel = {0}", channel));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Running unsubscribe()");
					pubnub.Unsubscribe<string> (channel, DisplayReturnMessage, DisplaySubscribeConnectStatusMessage, DisplaySubscribeDisconnectStatusMessage, DisplayErrorMessage);
                    /*pubnub.Unsubscribe<object>(channel, (object o) => {}
                    , (object o) => {}, (object o) => {}, (PubnubClientError e) => {});*/
					break;
				case "7":
					Console.WriteLine ("Enter CHANNEL name for Presence Unsubscribe. Use comma to enter multiple channels.");
					channel = Console.ReadLine ();

					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Channel = {0}", channel));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Running presence-unsubscribe()");
					pubnub.PresenceUnsubscribe<string> (channel, DisplayReturnMessage, DisplayPresenceConnectStatusMessage, DisplayPresenceDisconnectStatusMessage, DisplayErrorMessage);
					break;
				case "8":
					Console.WriteLine ("Running time()");
					pubnub.Time<string> (DisplayReturnMessage, DisplayErrorMessage);
					break;
				case "9":
					Console.WriteLine ("Running Disconnect/auto-Reconnect Subscriber Request Connection");
					pubnub.TerminateCurrentSubscriberRequest ();
					break;
				case "10":
					Console.WriteLine ("Disabling Network Connection (no internet)");
					Console.ForegroundColor = ConsoleColor.Red;
					Console.WriteLine ("Initiating Simulation of Internet non-availability");
					Console.WriteLine ("Until Choice=11 is entered, no operations will occur");
					Console.WriteLine ("NOTE: Publish from other pubnub clients can occur and those will be ");
					Console.WriteLine ("      captured upon choice=11 is entered provided resume on reconnect is enabled.");
					Console.ResetColor ();
					pubnub.EnableSimulateNetworkFailForTestingOnly ();
					break;
				case "11":
					Console.WriteLine ("Enabling Network Connection (yes internet)");
					Console.ForegroundColor = ConsoleColor.Red;
					Console.WriteLine ("Stopping Simulation of Internet non-availability");  
					Console.ResetColor ();
					pubnub.DisableSimulateNetworkFailForTestingOnly ();
					break;
				case "12":
					Console.WriteLine ("Enter CHANNEL name for PAM Grant. For Presence, Select Option 15.");
					channel = Console.ReadLine ();
					Console.WriteLine ("Read Access? Enter Y for Yes (default), N for No.");
					string readAccess = Console.ReadLine ();
					bool read = (readAccess.ToLower () == "n") ? false : true;
					Console.WriteLine ("Write Access? Enter Y for Yes (default), N for No.");
					string writeAccess = Console.ReadLine ();
					bool write = (writeAccess.ToLower () == "n") ? false : true;
					Console.WriteLine ("How many minutes do you want to allow Grant Access? Enter the number of minutes.");
					Console.WriteLine ("Default = 1440 minutes (24 hours). Press ENTER now to accept default value.");
					string grantTimeLimit = Console.ReadLine ();
					int grantTimeLimitInSeconds;
					Int32.TryParse (grantTimeLimit, out grantTimeLimitInSeconds);
					if (grantTimeLimitInSeconds == 0)
						grantTimeLimitInSeconds = 1440;

					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Channel = {0}", channel));
					Console.WriteLine (string.Format ("Read Access = {0}", read.ToString ()));
					Console.WriteLine (string.Format ("Write Access = {0}", write.ToString ()));
					Console.WriteLine (string.Format ("Grant Access Time Limit = {0}", grantTimeLimitInSeconds.ToString ()));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Running PamGrant()");
					pubnub.GrantAccess<string> (channel, read, write, grantTimeLimitInSeconds, DisplayReturnMessage, DisplayErrorMessage);
					break;
				case "13":
					Console.WriteLine ("Enter CHANNEL name for PAM Audit");
					channel = Console.ReadLine ();

					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Channel = {0}", channel));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Running PamAudit()");
					pubnub.AuditAccess<string> (channel, DisplayReturnMessage, DisplayErrorMessage);
					break;
				case "14":
					Console.WriteLine ("Enter CHANNEL name for PAM Revoke");
					channel = Console.ReadLine ();

					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Channel = {0}", channel));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Running PamRevoke()");
					pubnub.GrantAccess<string> (channel, false, false, DisplayReturnMessage, DisplayErrorMessage);
					break;
				case "15":
					Console.WriteLine ("Enter CHANNEL name for PAM Grant Presence.");
					channel = Console.ReadLine ();
					Console.WriteLine ("Read Access? Enter Y for Yes (default), N for No.");
					string readPresenceAccess = Console.ReadLine ();
					bool readPresence = (readPresenceAccess.ToLower () == "n") ? false : true;
					Console.WriteLine ("Write Access? Enter Y for Yes (default), N for No.");
					string writePresenceAccess = Console.ReadLine ();
					bool writePresence = (writePresenceAccess.ToLower () == "n") ? false : true;
					Console.WriteLine ("How many minutes do you want to allow Grant Presence Access? Enter the number of minutes.");
					Console.WriteLine ("Default = 1440 minutes (24 hours). Press ENTER now to accept default value.");
					string grantPresenceTimeLimit = Console.ReadLine ();
					int grantPresenceTimeLimitInSeconds;
					Int32.TryParse (grantPresenceTimeLimit, out grantPresenceTimeLimitInSeconds);
					if (grantPresenceTimeLimitInSeconds == 0)
						grantPresenceTimeLimitInSeconds = 1440;

					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Channel = {0}", channel));
					Console.WriteLine (string.Format ("Read Access = {0}", readPresence.ToString ()));
					Console.WriteLine (string.Format ("Write Access = {0}", writePresence.ToString ()));
					Console.WriteLine (string.Format ("Grant Access Time Limit = {0}", grantPresenceTimeLimitInSeconds.ToString ()));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Running PAM GrantPresenceAccess()");
					pubnub.GrantPresenceAccess<string> (channel, readPresence, writePresence, grantPresenceTimeLimitInSeconds, DisplayReturnMessage, DisplayErrorMessage);
					break;
				case "16":
					Console.WriteLine ("Enter CHANNEL name for PAM Presence Audit");
					channel = Console.ReadLine ();

					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Channel = {0}", channel));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Running PAM Presence Audit()");
					pubnub.AuditPresenceAccess<string> (channel, DisplayReturnMessage, DisplayErrorMessage);
					break;
				case "17":
					Console.WriteLine ("Enter CHANNEL name for PAM Presence Revoke");
					channel = Console.ReadLine ();

					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Channel = {0}", channel));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Running PAM Presence Revoke()");
					pubnub.GrantPresenceAccess<string> (channel, false, false, DisplayReturnMessage, DisplayErrorMessage);
					break;
				case "18":
					Console.WriteLine ("Enter Auth Key. Use comma to enter multiple Auth Keys.");
					Console.WriteLine ("If you don't want to use Auth Key, Press ENTER Key");
					authKey = Console.ReadLine ();
					pubnub.AuthenticationKey = authKey;

					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Auth Key(s) = {0}", authKey));
					Console.ResetColor ();
					Console.WriteLine ();

					break;
				case "19":
					Console.WriteLine ("Enabling simulation of Sleep/Suspend Mode");  
					pubnub.EnableMachineSleepModeForTestingOnly ();
					Console.ForegroundColor = ConsoleColor.Red;  
					Console.WriteLine ("Machine Sleep Mode simulation activated");
					Console.ResetColor ();  
					break;
				case "20":
					Console.WriteLine ("Disabling simulation of Sleep/Suspend Mode");  
					pubnub.DisableMachineSleepModeForTestingOnly ();
					Console.ForegroundColor = ConsoleColor.Red;  
					Console.WriteLine ("Simulation going to awake mode");  
					Console.ResetColor ();  
					break;
				case "21":
					Console.WriteLine ("Enter Presence Heartbeat in seconds");
					string pnHeartbeatInput = Console.ReadLine ();
					Int32.TryParse (pnHeartbeatInput, out presenceHeartbeat);
					pubnub.PresenceHeartbeat = presenceHeartbeat;
					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Presence Heartbeat = {0}", presenceHeartbeat));
					Console.ResetColor ();
					break;
				case "22":
					Console.WriteLine ("Enter Presence Heartbeat Interval in seconds");
					Console.WriteLine ("NOTE: We apply the logic Presence Heartbeat/2-1 seconds to calculate it." +
						"\nIf you enter a value greater than the value from this logic, \nwe will reset it to this calculated value.");
					string pnHeartbeatIntervalInput = Console.ReadLine ();
					Int32.TryParse (pnHeartbeatIntervalInput, out presenceHeartbeatInterval);
					pubnub.PresenceHeartbeatInterval = presenceHeartbeatInterval;
					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Presence Heartbeat Interval = {0}", pubnub.PresenceHeartbeatInterval));
					Console.ResetColor ();
					break;
				case "23":
					Console.WriteLine ("Enter channel name");
					string userStateChannel = Console.ReadLine ();
					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Channel = {0}", userStateChannel));
					Console.ResetColor ();

					Console.WriteLine ("User State will be accepted as dictionary key:value pair. You will be asked to enter multiple keys, to exit add an empty key");
					while (true) {
						Console.WriteLine ("Enter key. ");
						string keyUserState = Console.ReadLine ();
						if (string.IsNullOrEmpty (keyUserState.Trim ())) {
							Console.WriteLine ("dictionary key:value pair entry completed.");
							break;
						}
						Console.WriteLine ("Enter value");
						string valueUserState = Console.ReadLine ();
						int valueInt;
						double valueDouble;
						string currentUserState = "";
						if (Int32.TryParse (valueUserState, out valueInt)) {
							currentUserState = pubnub.SetLocalUserState (userStateChannel, keyUserState, valueInt);
						} else if (Double.TryParse (valueUserState, out valueDouble)) {
							currentUserState = pubnub.SetLocalUserState (userStateChannel, keyUserState, valueDouble);
						} else {
							currentUserState = pubnub.SetLocalUserState (userStateChannel, keyUserState, valueUserState);
						}

						Console.ForegroundColor = ConsoleColor.Blue;
						if (!string.IsNullOrEmpty (currentUserState)) {
							Console.WriteLine ("Current User State = {0}", currentUserState);
						} else {
							Console.Write ("No User State Exists");
						}
						Console.ResetColor ();
					}
					break;

				case "24":
					Console.WriteLine ("Enter channel name");
					string deleteUserStateChannel = Console.ReadLine ();
					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Channel = {0}", deleteUserStateChannel));
					Console.ResetColor ();

					Console.WriteLine ("Enter key of the local user state to be deleted");
					string deleteKeyUserState = Console.ReadLine ();
					string currentUserStateAfterDelete = pubnub.SetLocalUserState (deleteUserStateChannel, deleteKeyUserState, null);

					Console.ForegroundColor = ConsoleColor.Blue;
					if (!string.IsNullOrEmpty (currentUserStateAfterDelete)) {
						Console.WriteLine ("Current User State = {0}", currentUserStateAfterDelete);
					} else {
						Console.Write ("No User State Exists");
					}
					Console.ResetColor ();
					break;
				case "25":
					Console.WriteLine ("Enter channel name");
					string getUserStateChannel = Console.ReadLine ();
					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Channel = {0}", getUserStateChannel));
					Console.ResetColor ();

					string currentUserStateView = pubnub.GetLocalUserState (getUserStateChannel);

					Console.ForegroundColor = ConsoleColor.Blue;
					if (!string.IsNullOrEmpty (currentUserStateView)) {
						Console.WriteLine ("Current User State = {0}", currentUserStateView);
					} else {
						Console.Write ("No User State Exists");
					}
					Console.ResetColor ();
					break;
				case "26":
					Console.WriteLine ("Enter channel name");
					string setUserStateChannel = Console.ReadLine ();
					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Channel = {0}", setUserStateChannel));
					Console.ResetColor ();

					//Console.WriteLine ("NOTE: Hopefully you added local user state.");
					Console.WriteLine ("If you want to consider already created local user state, press ENTER");
					Console.WriteLine ("Else enter user state in json format (Eg. {\"key1\":\"value1\",\"key2\":\"value2\"}");
					string manualJsonUserState = Console.ReadLine ();

					string jsonUserState = "";
					if (string.IsNullOrEmpty (manualJsonUserState)) {
						jsonUserState = pubnub.GetLocalUserState (setUserStateChannel);
					} else {
						jsonUserState = manualJsonUserState;
					}
					if (jsonUserState == "" || jsonUserState == "{}") {
						Console.WriteLine ("Invalid User State");
						break;
					}
					Console.WriteLine ("Enter UUID. (Optional. Press ENTER to skip it)");
					string uuid = Console.ReadLine ();
					if (string.IsNullOrEmpty (uuid)) {
						pubnub.SetUserState<string> (setUserStateChannel, jsonUserState, DisplayReturnMessage, DisplayErrorMessage);
					} else {
						pubnub.SetUserState<string> (setUserStateChannel, uuid, jsonUserState, DisplayReturnMessage, DisplayErrorMessage);
					}
					break;
				case "27":
					Console.WriteLine ("Enter channel name");
					string getUserStateChannel2 = Console.ReadLine ();
					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Channel = {0}", getUserStateChannel2));
					Console.ResetColor ();

					Console.WriteLine ("Enter UUID. (Optional. Press ENTER to skip it)");
					string uuid2 = Console.ReadLine ();
					if (string.IsNullOrEmpty (uuid2)) {
						pubnub.GetUserState<string> (getUserStateChannel2, DisplayReturnMessage, DisplayErrorMessage);
					} else {
						pubnub.GetUserState<string> (getUserStateChannel2, uuid2, DisplayReturnMessage, DisplayErrorMessage);
					}
					break;
				case "28":
					Console.WriteLine ("Enter uuid for WhereNow. To consider SessionUUID, just press ENTER");
					string whereNowUuid = Console.ReadLine ();

					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("uuid = {0}", whereNowUuid));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Running Where_Now()");
					pubnub.WhereNow<string> (whereNowUuid, DisplayReturnMessage, DisplayErrorMessage);
					break;
				case "29":
					bool globalHereNowShowUUID = true;
					bool globalHereNowIncludeUserState = false;

					Console.WriteLine ("Show UUID List? Y or N? Default is Y. Press N for No Else press ENTER");
					string userChoiceGlobalHereNowShowUUID = Console.ReadLine ();
					if (userChoiceGlobalHereNowShowUUID.ToLower () == "n") {
						globalHereNowShowUUID = false;
					}
					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Show UUID = {0}", globalHereNowShowUUID));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Include User State? Y or N? Default is N. Press Y for Yes Else press ENTER");
					string userChoiceGlobalHereNowIncludeUserState = Console.ReadLine ();
					if (userChoiceGlobalHereNowIncludeUserState.ToLower () == "y") {
						globalHereNowIncludeUserState = true;
					}
					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Include User State = {0}", globalHereNowIncludeUserState));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Running Global HereNow()");
					pubnub.GlobalHereNow<string> (globalHereNowShowUUID, globalHereNowIncludeUserState, DisplayReturnMessage, DisplayErrorMessage);
					break;
				case "30":
					Console.WriteLine ("ENTER UUID.");
					string sessionUUID = Console.ReadLine ();
					pubnub.ChangeUUID (sessionUUID);
					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine ("UUID = {0}", pubnub.SessionUUID);
					Console.ResetColor ();
					break;
				default:
					Console.ForegroundColor = ConsoleColor.Red;
					Console.WriteLine ("INVALID CHOICE. ENTER 99 FOR EXIT OR QUIT");
					Console.ResetColor ();
					break;
				}
				if (!exitFlag) {
					userinput = Console.ReadLine ();
					Int32.TryParse (userinput, out currentUserChoice);
				}
			}

			Console.WriteLine ("\nPress any key to exit.\n\n");
			Console.ReadLine ();
		}
コード例 #13
0
ファイル: MainActivity.cs プロジェクト: umersain/c-sharp
        void HandleSetValues(object sender, EventArgs ea)
        {
            try {
                SetEventArgs cea = ea as SetEventArgs;

                if (cea.cds == CommonDialogStates.AuditSubscribe)
                {
                    Display("Running Channel Subscribe Audit");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.Audit()
                                                 .Channel(cea.channel)
                                                 .AuthKeys(new [] { cea.valueToSet })
                                                 .Async(new DemoAuditResult(Display))
                                                 );
                }
                else if (cea.cds == CommonDialogStates.RevokeSubscribe)
                {
                    Display("Running Subscribe Revoke");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.Grant().Channels(new [] { cea.channel })
                                                 .ChannelGroups(new [] { cea.valueToSet })
                                                 .Read(false).Write(false)
                                                 .Async(new DemoGrantResult(Display))
                                                 );
                }
                else if (cea.cds == CommonDialogStates.ChangeUuid)
                {
                    Display("Setting UUID");
                    pubnub.ChangeUUID(cea.valueToSet);
                    Display(string.Format("UUID set to {0}", config.Uuid));
                }
                else if (cea.cds == CommonDialogStates.WhereNow)
                {
                    Display("Running where now");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.WhereNow().Uuid(cea.valueToSet)
                                                 .Async(new DemoWhereNowResult(Display))
                                                 );
                }
                else if (cea.cds == CommonDialogStates.GetUserState)
                {
                    Display("Running get user state");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.GetPresenceState()
                                                 .Channels(new [] { cea.channel })
                                                 .ChannelGroups(new [] { cea.channelGroup })
                                                 .Uuid(cea.valueToSet)
                                                 .Async(new DemoPNGetStateResult(Display))
                                                 );
                }
                else if (cea.cds == CommonDialogStates.DeleteUserState)
                {
                    Display("Running delete user state");
                    ThreadPool.QueueUserWorkItem(o => {
                        Dictionary <string, object> delDic = new Dictionary <string, object> ();
                        delDic.Add(cea.valueToSet, null);
                        pubnub.SetPresenceState()
                        .Channels(new [] { cea.channel })
                        .ChannelGroups(new [] { cea.channelGroup })
                        .State(delDic)
                        .Async(new DemoPNSetStateResult(Display));
                    }
                                                 );
                }
                else if (cea.cds == CommonDialogStates.AddUserStateKeyValue)
                {
                    int    valueInt;
                    double valueDouble;

                    if (Int32.TryParse(cea.valueToSet2, out valueInt))
                    {
                        ThreadPool.QueueUserWorkItem(o => {
                            Dictionary <string, object> dicInt = new Dictionary <string, object> ();
                            dicInt.Add(cea.valueToSet, valueInt);

                            pubnub.SetPresenceState()
                            .Channels(new [] { cea.channel })
                            .ChannelGroups(new [] { cea.channelGroup })
                            .State(dicInt)
                            .Async(new DemoPNSetStateResult(Display));
                        }
                                                     );
                    }
                    else if (Double.TryParse(cea.valueToSet2, out valueDouble))
                    {
                        ThreadPool.QueueUserWorkItem(o => {
                            Dictionary <string, object> dicDouble = new Dictionary <string, object> ();
                            dicDouble.Add(cea.valueToSet, valueDouble);

                            pubnub.SetPresenceState()
                            .Channels(new [] { cea.channel })
                            .ChannelGroups(new [] { cea.channelGroup })
                            .State(dicDouble)
                            .Async(new DemoPNSetStateResult(Display));
                        }
                                                     );
                    }
                    else
                    {
                        ThreadPool.QueueUserWorkItem(o => {
                            Dictionary <string, object> dicStr = new Dictionary <string, object> ();
                            dicStr.Add(cea.valueToSet, cea.valueToSet2);

                            pubnub.SetPresenceState()
                            .Channels(new [] { cea.channel })
                            .ChannelGroups(new [] { cea.channelGroup })
                            .State(dicStr)
                            .Async(new DemoPNSetStateResult(Display));
                        });
                    }
                }
            } catch (Exception ex) {
                Display(ex.Message);
            } finally {
                CommonDialogFragment coroutine = sender as CommonDialogFragment;
                coroutine.SetValues -= HandleSetValues;
            }
        }
コード例 #14
0
        public void IfWhereNowIsCalledThenItShouldReturnInfo()
        {
            receivedWhereNowMessage = false;

            pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
            pubnub.SessionUUID = customUUID;
            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenAClientIsPresented";
            unitTest.TestCaseName = "IfWhereNowIsCalledThenItShouldReturnInfo";
            pubnub.PubnubUnitTest = unitTest;

            manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 1000 : 310 * 1000;
            whereNowChannel = "hello_my_channel";

            subscribeManualEvent = new ManualResetEvent(false);
            pubnub.Subscribe<string>(whereNowChannel, DummyMethodForSubscribe, SubscribeDummyMethodForConnectCallback, DummyErrorCallback);
            Thread.Sleep(1000);
            subscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);

            whereNowManualEvent = new ManualResetEvent(false);
            pubnub.WhereNow<string>(customUUID, ThenWhereNowShouldReturnMessage, DummyErrorCallback);
            whereNowManualEvent.WaitOne();

            if (!pubnub.PubnubUnitTest.EnableStubTest)
            {
                unsubscribeManualEvent = new ManualResetEvent(false);
                pubnub.Unsubscribe<string>(whereNowChannel, DummyMethodForUnSubscribe, UnsubscribeDummyMethodForConnectCallback, UnsubscribeDummyMethodForDisconnectCallback, DummyErrorCallback);
                Thread.Sleep(1000);
                unsubscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);
            }
            pubnub.EndPendingRequests();
            pubnub.PubnubUnitTest = null;
            pubnub = null;
            Assert.IsTrue(receivedWhereNowMessage, "where_now message not received");
        }
コード例 #15
0
        public void IfWhereNowIsCalledThenItShouldReturnInfo()
        {
            ThreadPool.QueueUserWorkItem((s) =>
            {
                receivedWhereNowMessage = false;

                Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
                PubnubUnitTest unitTest = new PubnubUnitTest();
                unitTest.TestClassName = "WhenAClientIsPresented";
                unitTest.TestCaseName = "IfWhereNowIsCalledThenItShouldReturnInfo";
                pubnub.PubnubUnitTest = unitTest;
                string uuid = "hello_my_uuid";

                mreWhereNow = new ManualResetEvent(false);
                pubnub.WhereNow<string>(uuid, ThenWhereNowShouldReturnMessage, DummyErrorCallback);
                mreWhereNow.WaitOne(60 * 1000);

                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    Assert.IsTrue(receivedWhereNowMessage, "where_now message not received");
                    TestComplete();
                });
            });
        }
コード例 #16
0
        public void IfWhereNowIsCalledThenItShouldReturnInfo()
        {
            receivedWhereNowMessage = false;

            Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenAClientIsPresented";
            unitTest.TestCaseName = "IfWhereNowIsCalledThenItShouldReturnInfo";
            pubnub.PubnubUnitTest = unitTest;
            string uuid = customUUID;
            pubnub.WhereNow<string>(uuid, ThenWhereNowShouldReturnMessage, DummyErrorCallback);
            whereNowManualEvent.WaitOne();
            pubnub.PubnubUnitTest = null;
            pubnub = null;
            Assert.IsTrue(receivedWhereNowMessage, "where_now message not received");
        }
コード例 #17
0
ファイル: MainActivity.cs プロジェクト: slvnperron/c-sharp
 void HandleSetValues(object sender, EventArgs ea)
 {
     try {
         SetEventArgs cea = ea as SetEventArgs;
         if (cea.cds == CommonDialogStates.Auth)
         {
             Display("Setting Auth Key");
             pubnub.AuthenticationKey = cea.valueToSet;
             Display("Auth Key set");
         }
         else if (cea.cds == CommonDialogStates.ChangeUuid)
         {
             Display("Setting UUID");
             pubnub.ChangeUUID(cea.valueToSet);
             Display(string.Format("UUID set to {0}", pubnub.SessionUUID));
         }
         else if (cea.cds == CommonDialogStates.WhereNow)
         {
             Display("Running where now");
             pubnub.WhereNow <string> (cea.valueToSet, DisplayReturnMessage, DisplayErrorMessage);
         }
         else if (cea.cds == CommonDialogStates.GetUserState)
         {
             Display("Running get user state");
             pubnub.GetUserState <string> (cea.channel, cea.valueToSet, DisplayReturnMessage, DisplayErrorMessage);
         }
         else if (cea.cds == CommonDialogStates.DeleteLocalUserState)
         {
             Display("Running delete local user state");
             string currentUserStateAfterDelete = pubnub.SetLocalUserState(cea.channel, cea.valueToSet, null);
             Display(string.Format("Current user state: {0}", currentUserStateAfterDelete));
         }
         else if (cea.cds == CommonDialogStates.PresenceHeartbeat)
         {
             Display("Setting presence heartbeat");
             //int check done in CommonDialogFragment
             pubnub.PresenceHeartbeat = int.Parse(cea.valueToSet);
             Display(string.Format("PresenceHeartbeat set to {0}", pubnub.PresenceHeartbeat));
         }
         else if (cea.cds == CommonDialogStates.PresenceHeartbeatInterval)
         {
             Display("Setting presence interval");
             //int check done in CommonDialogFragment
             pubnub.PresenceHeartbeatInterval = int.Parse(cea.valueToSet);
             Display(string.Format("PresenceHeartbeatInterval set to {0}", pubnub.PresenceHeartbeatInterval));
         }
         else if (cea.cds == CommonDialogStates.AddLocalUserState)
         {
             string currentState = pubnub.SetLocalUserState(cea.channel, cea.valueToSet, cea.valueToSet2);
             Display(string.Format("Current user state: {0}", currentState));
         }
         else if (cea.cds == CommonDialogStates.SetUserState)
         {
             string jsonUserState = "";
             if (string.IsNullOrEmpty(cea.valueToSet2))
             {
                 jsonUserState = pubnub.GetLocalUserState(cea.channel);
             }
             else
             {
                 jsonUserState = cea.valueToSet2;
             }
             pubnub.SetUserState <string> (cea.channel, cea.valueToSet, jsonUserState, DisplayReturnMessage, DisplayErrorMessage);
         }
     } catch (Exception ex) {
         Display(ex.Message);
     } finally {
         CommonDialogFragment coroutine = sender as CommonDialogFragment;
         coroutine.SetValues -= HandleSetValues;
     }
 }
コード例 #18
0
        static public void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper;

            PubnubProxy proxy = null;
            
            Console.WriteLine("HINT: TO TEST RE-CONNECT AND CATCH-UP,");
            Console.WriteLine("      DISCONNECT YOUR MACHINE FROM NETWORK/INTERNET AND ");
            Console.WriteLine("      RE-CONNECT YOUR MACHINE AFTER SOMETIME.");
            Console.WriteLine();
            Console.WriteLine("      IF NO NETWORK BEFORE MAX RE-TRY CONNECT,");
            Console.WriteLine("      NETWORK ERROR MESSAGE WILL BE SENT");
            Console.WriteLine();

            Console.WriteLine("Enter Pubnub Origin. Default Origin = pubsub.pubnub.com"); //TODO
            Console.WriteLine("If you want to accept default value, press ENTER.");
            string origin = Console.ReadLine();
            Console.ForegroundColor = ConsoleColor.Blue;
            if (origin.Trim() == "")
            {
                origin = "pubsub.pubnub.com";
                Console.WriteLine("Default Origin selected");
            }
            else
            {
                Console.WriteLine("Pubnub Origin Provided");
            }
            Console.ResetColor();
            Console.WriteLine();

            Console.WriteLine("Enable SSL? ENTER Y for Yes, else N");
            string enableSSL = Console.ReadLine();
            Console.ForegroundColor = ConsoleColor.Blue;
            if (enableSSL.Trim().ToLower() == "y")
            {
                Console.WriteLine("SSL Enabled");
            }
            else
            {
                Console.WriteLine("SSL NOT Enabled");
            }
            Console.ResetColor();
            Console.WriteLine();

            Console.WriteLine("ENTER cipher key for encryption feature.");
            Console.WriteLine("If you don't want to avail at this time, press ENTER.");
            string cipherKey = Console.ReadLine();
            Console.ForegroundColor = ConsoleColor.Blue;
            if (cipherKey.Trim().Length > 0)
            {
                Console.WriteLine("Cipher key provided.");
            }
            else
            {
                Console.WriteLine("No Cipher key provided");
            }
            Console.ResetColor();
            Console.WriteLine();

            Console.WriteLine("ENTER subscribe key.");
            Console.WriteLine("If you want to accept default demo subscribe key, press ENTER.");
            string subscribeKey = Console.ReadLine();
            Console.ForegroundColor = ConsoleColor.Blue;
            if (subscribeKey.Trim().Length > 0)
            {
                Console.WriteLine("Subscribe key provided.");
            }
            else
            {
                Console.WriteLine("Default demo subscribe key provided");
                subscribeKey = "demo";
            }
            Console.ResetColor();
            Console.WriteLine();

            Console.WriteLine("ENTER publish key.");
            Console.WriteLine("If you want to accept default demo publish key, press ENTER.");
            string publishKey = Console.ReadLine();
            Console.ForegroundColor = ConsoleColor.Blue;
            if (publishKey.Trim().Length > 0)
            {
                Console.WriteLine("Publish key provided.");
            }
            else
            {
                Console.WriteLine("Default demo publish key provided");
                publishKey = "demo";
            }
            Console.ResetColor();
            Console.WriteLine();

            Console.WriteLine("ENTER secret key.");
            Console.WriteLine("If you don't want to avail at this time, press ENTER.");
            string secretKey = Console.ReadLine();
            Console.ForegroundColor = ConsoleColor.Blue;
            if (secretKey.Trim().Length > 0)
            {
                Console.WriteLine("Secret key provided.");
            }
            else
            {
                Console.WriteLine("Default demo Secret key provided");
                secretKey = "demo";
            }
            Console.ResetColor();
            Console.WriteLine();

            pubnub = new Pubnub(publishKey, subscribeKey, secretKey, cipherKey,
                (enableSSL.Trim().ToLower() == "y") ? true : false);

            pubnub.Origin = origin;

            Console.WriteLine("Use Custom Session UUID? ENTER Y for Yes, else N");
            string enableCustomUUID = Console.ReadLine();
            if (enableCustomUUID.Trim().ToLower() == "y")
            {
                Console.WriteLine("ENTER Session UUID.");
                string sessionUUID = Console.ReadLine();
                pubnub.SessionUUID = sessionUUID;
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("Accepted Custom Session UUID.");
                Console.ResetColor();
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("Default Session UUID opted.");
                Console.ResetColor();
            }
            Console.WriteLine();

            Console.WriteLine("By default Resume On Reconnect is enabled. Do you want to disable it? ENTER Y for Yes, else N");
            string disableResumeOnReconnect = Console.ReadLine();
            Console.ForegroundColor = ConsoleColor.Blue;
            if (disableResumeOnReconnect.Trim().ToLower() == "y")
            {
                Console.WriteLine("Resume On Reconnect Disabled");
                pubnub.EnableResumeOnReconnect = false;
            }
            else
            {
                Console.WriteLine("Resume On Reconnect Enabled by default");
                pubnub.EnableResumeOnReconnect = true;
            }
            Console.ResetColor();
            Console.WriteLine();

            Console.WriteLine("Subscribe Timeout = 310 seconds (default). Enter the value to change, else press ENTER");
            string subscribeTimeoutEntry = Console.ReadLine();
            int subscribeTimeout;
            Int32.TryParse(subscribeTimeoutEntry, out subscribeTimeout);
            Console.ForegroundColor = ConsoleColor.Blue;
            if (subscribeTimeout > 0)
            {
                Console.WriteLine("Subscribe Timeout = {0}",subscribeTimeout);
                pubnub.SubscribeTimeout = subscribeTimeout;
            }
            else
            {
                Console.WriteLine("Subscribe Timeout = {0} (default)", pubnub.SubscribeTimeout);
            }
            Console.ResetColor();
            Console.WriteLine();

            Console.WriteLine("Non Subscribe Timeout = 15 seconds (default). Enter the value to change, else press ENTER");
            string nonSubscribeTimeoutEntry = Console.ReadLine();
            int nonSubscribeTimeout;
            Int32.TryParse(nonSubscribeTimeoutEntry, out nonSubscribeTimeout);
            Console.ForegroundColor = ConsoleColor.Blue;
            if (nonSubscribeTimeout > 0)
            {
                Console.WriteLine("Non Subscribe Timeout = {0}", nonSubscribeTimeout);
                pubnub.NonSubscribeTimeout = nonSubscribeTimeout;
            }
            else
            {
                Console.WriteLine("Non Subscribe Timeout = {0} (default)", pubnub.NonSubscribeTimeout);
            }
            Console.ResetColor();
            Console.WriteLine();

            Console.WriteLine("Network Check MAX retries = 50 (default). Enter the value to change, else press ENTER");
            string networkCheckMaxRetriesEntry = Console.ReadLine();
            int networkCheckMaxRetries;
            Int32.TryParse(networkCheckMaxRetriesEntry, out networkCheckMaxRetries);
            Console.ForegroundColor = ConsoleColor.Blue;
            if (networkCheckMaxRetries > 0)
            {
                Console.WriteLine("Network Check MAX retries = {0}", networkCheckMaxRetries);
                pubnub.NetworkCheckMaxRetries = networkCheckMaxRetries;
            }
            else
            {
                Console.WriteLine("Network Check MAX retries = {0} (default)", pubnub.NetworkCheckMaxRetries);
            }
            Console.ResetColor();
            Console.WriteLine();

            Console.WriteLine("Network Check Retry Interval = 10 seconds (default). Enter the value to change, else press ENTER");
            string networkCheckRetryIntervalEntry = Console.ReadLine();
            int networkCheckRetryInterval;
            Int32.TryParse(networkCheckRetryIntervalEntry, out networkCheckRetryInterval);
            Console.ForegroundColor = ConsoleColor.Blue;
            if (networkCheckRetryInterval > 0)
            {
                Console.WriteLine("Network Check Retry Interval = {0} seconds", networkCheckRetryInterval);
                pubnub.NetworkCheckRetryInterval = networkCheckRetryInterval;
            }
            else
            {
                Console.WriteLine("Network Check Retry Interval = {0} seconds (default)", pubnub.NetworkCheckRetryInterval);
            }
            Console.ResetColor();
            Console.WriteLine();

            Console.WriteLine("Local Client Heartbeat Interval = 15 seconds (default). Enter the value to change, else press ENTER");
            string heartbeatIntervalEntry = Console.ReadLine();
            int localClientHeartbeatInterval;
            Int32.TryParse(heartbeatIntervalEntry, out localClientHeartbeatInterval);
            Console.ForegroundColor = ConsoleColor.Blue;
            if (localClientHeartbeatInterval > 0)
            {
                Console.WriteLine("Heartbeat Interval = {0} seconds", localClientHeartbeatInterval);
                pubnub.LocalClientHeartbeatInterval = localClientHeartbeatInterval;
            }
            else
            {
                Console.WriteLine("Heartbeat Interval = {0} seconds (default)", pubnub.LocalClientHeartbeatInterval);
            }
            Console.ResetColor();
            Console.WriteLine();

            Console.WriteLine("HTTP Proxy Server with NTLM authentication(IP + username/pwd) exists? ENTER Y for Yes, else N");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("NOTE: Pubnub example is being tested with CCProxy 7.3 Demo version");
            Console.ResetColor();
            string enableProxy = Console.ReadLine();
            if (enableProxy.Trim().ToLower() == "y")
            {
                bool proxyAccepted = false;
                while (!proxyAccepted)
                {
                    Console.WriteLine("ENTER proxy server name or IP.");
                    string proxyServer = Console.ReadLine();
                    Console.WriteLine("ENTER port number of proxy server.");
                    string proxyPort = Console.ReadLine();
                    int port;
                    Int32.TryParse(proxyPort, out port);
                    Console.WriteLine("ENTER user name for proxy server authentication.");
                    string proxyUsername = Console.ReadLine();
                    Console.WriteLine("ENTER password for proxy server authentication.");
                    string proxyPassword = Console.ReadLine();
                    
                    proxy = new PubnubProxy();
                    proxy.ProxyServer = proxyServer;
                    proxy.ProxyPort = port;
                    proxy.ProxyUserName = proxyUsername;
                    proxy.ProxyPassword = proxyPassword;
                    Console.ForegroundColor = ConsoleColor.Blue;
                    try
                    {
                        pubnub.Proxy = proxy;
                        proxyAccepted = true;
                        Console.WriteLine("Proxy details accepted");
                        Console.ResetColor();
                    }
                    catch (MissingFieldException mse)
                    {
                        Console.WriteLine(mse.Message);
                        Console.WriteLine("Please RE-ENTER Proxy Server details.");
                    }
                    Console.ResetColor();
                }
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("No Proxy");
                Console.ResetColor();
            }
            Console.WriteLine();

            Console.WriteLine("Enter Auth Key. If you don't want to use Auth Key, Press ENTER Key");
            authKey = Console.ReadLine();
            pubnub.AuthenticationKey = authKey;

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine(string.Format("Auth Key = {0}", authKey));
            Console.ResetColor();
            Console.WriteLine();

            Console.WriteLine("Display ErrorCallback messages? Enter Y for Yes, Else N for No.");
            Console.WriteLine("Default = N  ");
            string displayErrMessage = Console.ReadLine();
            Console.ForegroundColor = ConsoleColor.Blue;
            if (displayErrMessage.Trim().ToLower() == "y" )
            {
                showErrorMessageSegments = true;
                Console.WriteLine("ErrorCallback messages will  be displayed");
            }
            else
            {
                showErrorMessageSegments = false;
                Console.WriteLine("ErrorCallback messages will NOT be displayed.");
            }
            Console.ResetColor();
            Console.WriteLine();

            Console.WriteLine("Display Debug Info in ErrorCallback messages? Enter Y for Yes, Else N for No.");
            Console.WriteLine("Default = Y  ");
            string debugMessage = Console.ReadLine();
            Console.ForegroundColor = ConsoleColor.Blue;
            if (debugMessage.Trim().ToLower() == "n")
            {
                showDebugMessages = false;
                Console.WriteLine("ErrorCallback messages will NOT  be displayed");
            }
            else
            {
                showDebugMessages = true;
                Console.WriteLine("Debug messages will be displayed.");
            }
            Console.ResetColor();
            Console.WriteLine();


            bool exitFlag = false;
            string channel="";
            string channelGroup = "";
            int currentUserChoice = 0;
            string userinput = "";
            Console.WriteLine("");
            while (!exitFlag)
            {
                if (currentUserChoice < 1 || (currentUserChoice > 40 && currentUserChoice != 99))
                {
                    Console.WriteLine("ENTER 1 FOR Subscribe channel/channelgroup");
                    Console.WriteLine("ENTER 2 FOR Publish");
                    Console.WriteLine("ENTER 3 FOR Presence channel/channelgroup");
                    Console.WriteLine("ENTER 4 FOR Detailed History");
                    Console.WriteLine("ENTER 5 FOR Here_Now");
                    Console.WriteLine("ENTER 6 FOR Unsubscribe");
                    Console.WriteLine("ENTER 7 FOR Presence-Unsubscribe");
                    Console.WriteLine("ENTER 8 FOR Time");
                    Console.WriteLine("ENTER 9 FOR Disconnect/Reconnect existing Subscriber(s) (when internet is available)");
                    Console.WriteLine("ENTER 10 TO Disable Network Connection (no internet)");
                    Console.WriteLine("ENTER 11 TO Enable Network Connection (yes internet)");
                    Console.WriteLine("ENTER 12 FOR Grant Access to channel/ChannelGroup");
                    Console.WriteLine("ENTER 13 FOR Audit Access to channel/ChannelGroup");
                    Console.WriteLine("ENTER 14 FOR Revoke Access to channel/ChannelGroup");
                    Console.WriteLine("ENTER 15 FOR Grant Access to Presence Channel/ChannelGroup");
                    Console.WriteLine("ENTER 16 FOR Audit Access to Presence Channel/ChannelGroup");
                    Console.WriteLine("ENTER 17 FOR Revoke Access to Presence Channel/ChannelGroup");
                    Console.WriteLine("ENTER 18 FOR Change/Update Auth Key (Current value = {0})", pubnub.AuthenticationKey);
                    Console.WriteLine("ENTER 19 TO Simulate Machine Sleep Mode");
                    Console.WriteLine("ENTER 20 TO Simulate Machine Awake Mode");
                    Console.WriteLine("ENTER 21 TO Set Presence Heartbeat (Current value = {0} sec)", pubnub.PresenceHeartbeat);
                    Console.WriteLine("ENTER 22 TO Set Presence Heartbeat Interval (Current value = {0} sec)", pubnub.PresenceHeartbeatInterval);
                    Console.WriteLine("Enter 23 TO Set User State by Add/Modify Key-Pair");
                    Console.WriteLine("Enter 24 TO Set User State by Deleting existing Key-Pair");
                    Console.WriteLine("Enter 25 TO Set User State with direct json string");
                    Console.WriteLine("Enter 26 TO Get User State");
                    Console.WriteLine("Enter 27 FOR WhereNow");
                    Console.WriteLine("Enter 28 FOR GlobalHere_Now");
                    Console.WriteLine("Enter 29 TO change UUID. (Current value = {0})", pubnub.SessionUUID);
                    Console.WriteLine("Enter 38 FOR Channel Group - Add channel(s)");
                    Console.WriteLine("Enter 39 FOR Channel Group - Remove channel/group/namespace");
                    Console.WriteLine("Enter 40 FOR Channel Group - Get channel(s)/namespace(s)");
                    Console.WriteLine("ENTER 99 FOR EXIT OR QUIT");

                    userinput = Console.ReadLine();
                }
                switch (userinput)
                {
                    case "99":
                        exitFlag = true;
                        pubnub.EndPendingRequests();
                        break;
                    case "1":
                        Console.WriteLine("Enter CHANNEL name for subscribe. Use comma to enter multiple channels.");
                        Console.WriteLine("NOTE: If you want to consider only Channel Group(s), just hit ENTER");
                        channel = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}",channel));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Enter CHANNEL GROUP name for subscribe. Use comma to enter multiple channel groups.");
                        Console.WriteLine("To denote a namespaced CHANNEL GROUP, use the colon (:) character with the format namespace:channelgroup.");
                        Console.WriteLine("NOTE: If you want to consider only Channel(s), assuming you already entered , just hit ENTER");
                        channelGroup = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel Group= {0}", channelGroup));
                        Console.ResetColor();
                        Console.WriteLine();

                        if (channel.Length <= 0 && channelGroup.Length <= 0)
                        {
                            Console.WriteLine("To run subscribe(), atleast provide either channel name or channel group name or both");
                        }
                        else
                        {
                            Console.WriteLine("Running subscribe()");
                            pubnub.Subscribe<string>(channel, channelGroup, DisplaySubscribeReturnMessage, DisplaySubscribeConnectStatusMessage, DisplayErrorMessage);
                        }
                        break;
                    case "2":
                        Console.WriteLine("Enter CHANNEL name for publish.");
                        channel = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}",channel));
                        Console.ResetColor();

                        if (channel == "")
                        {
                            Console.WriteLine("Invalid CHANNEL name");
                            break;
                        }
                        Console.WriteLine("Store In History? Enter Y for Yes or N for No. To accept default(Y), just press ENTER");
                        string storeInHistory = Console.ReadLine();
                        bool store = true;
                        if (storeInHistory.ToLower() == "n")
                        {
                            store = false;
                        }

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Store In History = {0}", storeInHistory));
                        Console.ResetColor();




                        Console.WriteLine("Direct JSON String? Enter Y for Yes or N for No. To accept default(N), just press ENTER");
                        string directJson = Console.ReadLine();
                        bool jsonPublish = false;
                        if (directJson.ToLower() == "y")
                        {
                            jsonPublish = true;
                            pubnub.EnableJsonEncodingForPublish = false;
                        }
                        else
                        {
                            pubnub.EnableJsonEncodingForPublish = true;
                        }

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Direct JSON String = {0}", jsonPublish));
                        Console.ResetColor();



                        /* TO TEST SMALL TEXT PUBLISH ONLY */
                        Console.WriteLine("Enter the message for publish and press ENTER key to submit");
                        //string publishMsg = Console.ReadLine();

                        /* UNCOMMENT THE FOLLOWING CODE BLOCK TO TEST LARGE TEXT PUBLISH ONLY */
                        #region Code To Test Large Text Publish
                        ConsoleKeyInfo enteredKey;
                        StringBuilder publishBuilder = new StringBuilder();
                        do
                        {
                            enteredKey = Console.ReadKey(); //This logic is being used to capture > 2K input in console window
                            if (enteredKey.Key != ConsoleKey.Enter)
                            {
                                publishBuilder.Append(enteredKey.KeyChar);
                            }
                        } while (enteredKey.Key != ConsoleKey.Enter);
                        string publishMsg = publishBuilder.ToString();
                        #endregion
                        
                        Console.WriteLine("Running publish()");

                        double doubleData;
                        int intData;
                        if (int.TryParse(publishMsg, out intData)) //capture numeric data
                        {
                            pubnub.Publish<string>(channel, intData, store, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        else if (double.TryParse(publishMsg, out doubleData)) //capture numeric data
                        {
                            pubnub.Publish<string>(channel, doubleData, store, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        else
                        {
                            //check whether any numeric is sent in double quotes
                            if (publishMsg.IndexOf("\"") == 0 && publishMsg.LastIndexOf("\"") == publishMsg.Length - 1)
                            {
                                string strMsg = publishMsg.Substring(1, publishMsg.Length - 2);
                                if (int.TryParse(strMsg, out intData))
                                {
                                    pubnub.Publish<string>(channel, strMsg, store, DisplayReturnMessage, DisplayErrorMessage);
                                }
                                else if (double.TryParse(strMsg, out doubleData))
                                {
                                    pubnub.Publish<string>(channel, strMsg, store, DisplayReturnMessage, DisplayErrorMessage);
                                }
                                else
                                {
                                    pubnub.Publish<string>(channel, publishMsg, store, DisplayReturnMessage, DisplayErrorMessage);
                                }
                            }
                            else
                            {
                                pubnub.Publish<string>(channel, publishMsg, store, DisplayReturnMessage, DisplayErrorMessage);
                            }
                        }
                        break;
                    case "3":
                        Console.WriteLine("Enter CHANNEL name for presence. Use comma to enter multiple channels.");
                        Console.WriteLine("NOTE: If you want to consider only Presence Channel Group(s), just hit ENTER");
                        channel = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Presence Channel = {0}",channel));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Enter CHANNEL GROUP name for presence. Use comma to enter multiple channel groups.");
                        Console.WriteLine("To denote a namespaced CHANNEL GROUP, use the colon (:) character with the format namespace:channelgroup.");
                        Console.WriteLine("NOTE: If you want to consider only Presence Channel(s), assuming you already entered, just hit ENTER");
                        channelGroup = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Presence Channel Group= {0}", channelGroup));
                        Console.ResetColor();
                        Console.WriteLine();

                        if (channel.Length <= 0 && channelGroup.Length <= 0)
                        {
                            Console.WriteLine("To run presence(), atleast provide either channel name or channel group name or both");
                        }
                        else
                        {
                            Console.WriteLine("Running presence()");
                            pubnub.Presence<string>(channel, channelGroup, DisplaySubscribeReturnMessage, DisplaySubscribeConnectStatusMessage, DisplayErrorMessage);
                        }
                        break;
                    case "4":
                        Console.WriteLine("Enter CHANNEL name for Detailed History");
                        channel = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}",channel));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Running detailed history()");
                        pubnub.DetailedHistory<string>(channel, 100, DisplayReturnMessage, DisplayErrorMessage);
                        break;
                    case "5":
                        bool showUUID = true;
                        bool includeUserState = false;

                        Console.WriteLine("Enter CHANNEL name for HereNow");
                        channel = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}",channel));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Show UUID List? Y or N? Default is Y. Press N for No Else press ENTER");
                        string userChoiceShowUUID = Console.ReadLine();
                        if (userChoiceShowUUID.ToLower() == "n")
                        {
                            showUUID = false;
                        }
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Show UUID = {0}",showUUID));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Include User State? Y or N? Default is N. Press Y for Yes Else press ENTER");
                        string userChoiceIncludeUserState = Console.ReadLine();
                        if (userChoiceIncludeUserState.ToLower() == "y")
                        {
                            includeUserState = true;
                        }
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Include User State = {0}", includeUserState));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Running Here_Now()");
                        pubnub.HereNow<string>(channel, showUUID, includeUserState, DisplayReturnMessage, DisplayErrorMessage);
                        break;
                    case "6":
                        Console.WriteLine("Enter CHANNEL name for Unsubscribe. Use comma to enter multiple channels.");
                        Console.WriteLine("NOTE: If you want to consider only Channel Group, just hit ENTER");
                        channel = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}",channel));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Enter channel group name");
                        Console.WriteLine("NOTE: If you want to consider only Channel, just hit ENTER");
                        channelGroup = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("ChannelGroup = {0}", channelGroup));
                        Console.ResetColor();

                        if (channel.Length <= 0 && channelGroup.Length <= 0)
                        {
                            Console.WriteLine("To run unsubscribe(), atleast provide either channel name or channel group name or both");
                        }
                        else
                        {
                            Console.WriteLine("Running unsubscribe()");
                            pubnub.Unsubscribe<string>(channel, channelGroup, DisplayReturnMessage, DisplaySubscribeConnectStatusMessage, DisplaySubscribeDisconnectStatusMessage, DisplayErrorMessage);
                        }
                        break;
                    case "7":
                        Console.WriteLine("Enter CHANNEL name for Presence Unsubscribe. Use comma to enter multiple channels.");
                        channel = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}",channel));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Enter channel group name for Presence Unsubscribe");
                        Console.WriteLine("NOTE: If you want to consider only Channel, just hit ENTER");
                        channelGroup = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("ChannelGroup = {0}", channelGroup));
                        Console.ResetColor();

                        if (channel.Length <= 0 && channelGroup.Length <= 0)
                        {
                            Console.WriteLine("To run presence-unsubscribe(), atleast provide either channel name or channel group name or both");
                        }
                        else
                        {
                            Console.WriteLine("Running presence-unsubscribe()");
                            pubnub.PresenceUnsubscribe<string>(channel, channelGroup, DisplayReturnMessage, DisplayPresenceConnectStatusMessage, DisplayPresenceDisconnectStatusMessage, DisplayErrorMessage);
                        }
                        break;
                    case "8":
                        Console.WriteLine("Running time()");
                        pubnub.Time<string>(DisplayReturnMessage, DisplayErrorMessage);
                        break;
                    case "9":
                        Console.WriteLine("Running Disconnect/auto-Reconnect Subscriber Request Connection");
                        pubnub.TerminateCurrentSubscriberRequest();
                        break;
                    case "10":
                        Console.WriteLine("Disabling Network Connection (no internet)");
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Initiating Simulation of Internet non-availability");
                        Console.WriteLine("Until Choice=11 is entered, no operations will occur");
                        Console.WriteLine("NOTE: Publish from other pubnub clients can occur and those will be ");
                        Console.WriteLine("      captured upon choice=11 is entered provided resume on reconnect is enabled.");
                        Console.ResetColor();
                        pubnub.EnableSimulateNetworkFailForTestingOnly();
                        break;
                    case "11":
                        Console.WriteLine("Enabling Network Connection (yes internet)");
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Stopping Simulation of Internet non-availability");  
                        Console.ResetColor();
                        pubnub.DisableSimulateNetworkFailForTestingOnly();
                        break;
                    case "12":
                        Console.WriteLine("Enter CHANNEL name for PAM Grant. For Presence, Select Option 15.");
                        Console.WriteLine("To enter CHANNEL GROUP name, just hit ENTER");
                        channel = Console.ReadLine();

                        if (channel.Trim().Length <= 0)
                        {
                            channel = "";
                            Console.WriteLine("Enter CHANNEL GROUP name for PAM Grant.");
                            channelGroup = Console.ReadLine();
                        }
                        if (channel.Trim().Length <= 0 && channelGroup.Trim().Length <= 0)
                        {
                            Console.WriteLine("Channel or ChannelGroup not provided. Please try again.");
                            break;
                        }
                        Console.WriteLine("Enter the auth_key for PAM Grant (optional)");
                        Console.WriteLine("Press Enter Key if there is no auth_key at this time.");
                        string authGrant = Console.ReadLine();
                        
                        Console.WriteLine("Read Access? Enter Y for Yes (default), N for No.");
                        string readAccess = Console.ReadLine();
                        bool read = (readAccess.ToLower() == "n") ? false : true;

                        bool write = false;
                        if (channel.Trim().Length > 0)
                        {
                            Console.WriteLine("Write Access? Enter Y for Yes (default), N for No.");
                            string writeAccess = Console.ReadLine();
                            write = (writeAccess.ToLower() == "n") ? false : true;
                        }

                        bool manage=false;
                        if (channel.Trim().Length <= 0)
                        {
                            Console.WriteLine("Manage Access? Enter Y for Yes (default), N for No.");
                            string manageAccess = Console.ReadLine();
                            manage = (manageAccess.ToLower() == "n") ? false : true;
                        }
                        Console.WriteLine("How many minutes do you want to allow Grant Access? Enter the number of minutes.");
                        Console.WriteLine("Default = 1440 minutes (24 hours). Press ENTER now to accept default value.");
                        int grantTimeLimitInMinutes;
                        string grantTimeLimit = Console.ReadLine();
                        if (string.IsNullOrEmpty(grantTimeLimit.Trim()))
                        {
                            grantTimeLimitInMinutes = 1440;
                        }
                        else
                        {
                            Int32.TryParse(grantTimeLimit, out grantTimeLimitInMinutes);
                            if (grantTimeLimitInMinutes < 0) grantTimeLimitInMinutes = 1440;
                        }

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}",channel));
                        Console.WriteLine(string.Format("ChannelGroup = {0}", channelGroup));
                        Console.WriteLine(string.Format("auth_key = {0}", authGrant));
                        Console.WriteLine(string.Format("Read Access = {0}", read.ToString()));
                        if (channel.Trim().Length > 0)
                        {
                            Console.WriteLine(string.Format("Write Access = {0}", write.ToString()));
                        }
                        if (channel.Trim().Length <= 0)
                        {
                            Console.WriteLine(string.Format("Manage Access = {0}", manage.ToString()));
                        }
                        Console.WriteLine(string.Format("Grant Access Time Limit = {0}", grantTimeLimitInMinutes.ToString()));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Running PamGrant()");
                        if (channel.Trim().Length > 0)
                        {
                            pubnub.GrantAccess<string>(channel, authGrant, read, write, grantTimeLimitInMinutes, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        else
                        {
                            pubnub.ChannelGroupGrantAccess<string>(channelGroup, authGrant, read, manage, grantTimeLimitInMinutes, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        break;
                    case "13":
                        Console.WriteLine("Enter CHANNEL name for PAM Audit");
                        Console.WriteLine("To enter CHANNEL GROUP name, just hit ENTER");
                        channel = Console.ReadLine();

                        if (channel.Trim().Length <= 0)
                        {
                            Console.WriteLine("Enter CHANNEL GROUP name for PAM Audit.");
                            channelGroup = Console.ReadLine();
                        }
                        if (channel.Trim().Length <= 0 && channelGroup.Trim().Length <= 0)
                        {
                            Console.WriteLine("Channel or ChannelGroup not provided. Please try again.");
                            break;
                        }

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}", channel));
                        Console.ResetColor();
                        Console.WriteLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("ChannelGroup = {0}", channelGroup));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Enter the auth_key for PAM Audit (optional)");
                        Console.WriteLine("Press Enter Key if there is no auth_key at this time.");
                        string authAudit = Console.ReadLine();
                        
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("auth_key = {0}", authAudit));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Running PamAudit()");
                        if (channel.Trim().Length > 0)
                        {
                            pubnub.AuditAccess<string>(channel, authAudit, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        else
                        {
                            pubnub.ChannelGroupAuditAccess<string>(channelGroup, authAudit, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        break;
                    case "14":
                        Console.WriteLine("Enter CHANNEL name for PAM Revoke");
                        Console.WriteLine("To enter CHANNEL GROUP name, just hit ENTER");
                        channel = Console.ReadLine();
                        
                        if (channel.Trim().Length <= 0)
                        {
                            Console.WriteLine("Enter CHANNEL GROUP name for PAM Revoke.");
                            channelGroup = Console.ReadLine();
                        }
                        if (channel.Trim().Length <= 0 && channelGroup.Trim().Length <= 0)
                        {
                            channel = "";
                            Console.WriteLine("Channel or ChannelGroup not provided. Please try again.");
                            break;
                        }
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}", channel));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("ChannelGroup = {0}", channelGroup));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Enter the auth_key for PAM Revoke (optional)");
                        Console.WriteLine("Press Enter Key if there is no auth_key at this time.");
                        string authRevoke = Console.ReadLine();
                        
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("auth_key = {0}", authRevoke));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Running PamRevoke()");
                        if (channel.Trim().Length > 0)
                        {
                            pubnub.GrantAccess<string>(channel, authRevoke, false, false, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        else
                        {
                            pubnub.ChannelGroupGrantAccess<string>(channelGroup, authRevoke, false, false, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        break;
                    case "15":
                        Console.WriteLine("Enter CHANNEL name for PAM Grant Presence.");
                        Console.WriteLine("To enter CHANNEL GROUP name, just hit ENTER");
                        channel = Console.ReadLine();

                        if (channel.Trim().Length <= 0)
                        {
                            channel = "";
                            Console.WriteLine("Enter CHANNEL GROUP name for PAM Grant Presence.");
                            channelGroup = Console.ReadLine();
                        }
                        if (channel.Trim().Length <= 0 && channelGroup.Trim().Length <= 0)
                        {
                            Console.WriteLine("Channel or ChannelGroup not provided. Please try again.");
                            break;
                        }
                        
                        Console.WriteLine("Enter the auth_key for PAM Grant Presence (optional)");
                        Console.WriteLine("Press Enter Key if there is no auth_key at this time.");
                        string authGrantPresence = Console.ReadLine();
                        
                        Console.WriteLine("Read Access? Enter Y for Yes (default), N for No.");
                        string readPresenceAccess = Console.ReadLine();
                        bool readPresence = (readPresenceAccess.ToLower() == "n") ? false : true;

                        bool writePresence = false;
                        if (channel.Trim().Length > 0)
                        {
                            Console.WriteLine("Write Access? Enter Y for Yes (default), N for No.");
                            string writePresenceAccess = Console.ReadLine();
                            writePresence = (writePresenceAccess.ToLower() == "n") ? false : true;
                        }

                        bool managePresence=false;
                        if (channel.Trim().Length <= 0)
                        {
                            Console.WriteLine("Manage Access? Enter Y for Yes (default), N for No.");
                            string manageAccess = Console.ReadLine();
                            managePresence = (manageAccess.ToLower() == "n") ? false : true;
                        }

                        Console.WriteLine("How many minutes do you want to allow Grant Presence Access? Enter the number of minutes.");
                        Console.WriteLine("Default = 1440 minutes (24 hours). Press ENTER now to accept default value.");
                        int grantPresenceTimeLimitInMinutes;
                        string grantPresenceTimeLimit = Console.ReadLine();
                        if (string.IsNullOrEmpty(grantPresenceTimeLimit.Trim()))
                        {
                            grantPresenceTimeLimitInMinutes = 1440;
                        }
                        else
                        {
                            Int32.TryParse(grantPresenceTimeLimit, out grantPresenceTimeLimitInMinutes);
                            if (grantPresenceTimeLimitInMinutes < 0) grantPresenceTimeLimitInMinutes = 1440;
                        }

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}", channel));
                        Console.WriteLine(string.Format("ChannelGroup = {0}", channelGroup));
                        Console.WriteLine(string.Format("auth_key = {0}", authGrantPresence));
                        Console.WriteLine(string.Format("Read Access = {0}", readPresence.ToString()));
                        if (channel.Trim().Length > 0)
                        {
                            Console.WriteLine(string.Format("Write Access = {0}", writePresence.ToString()));
                        }
                        if (channel.Trim().Length <= 0)
                        {
                            Console.WriteLine(string.Format("Manage Access = {0}", managePresence.ToString()));
                        }
                        Console.WriteLine(string.Format("Grant Access Time Limit = {0}", grantPresenceTimeLimitInMinutes.ToString()));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Running PAM GrantPresenceAccess()");
                        if (channel.Trim().Length > 0)
                        {
                            pubnub.GrantPresenceAccess<string>(channel, authGrantPresence, readPresence, writePresence, grantPresenceTimeLimitInMinutes, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        else
                        {
                            pubnub.ChannelGroupGrantPresenceAccess<string>(channelGroup, authGrantPresence, readPresence, managePresence, grantPresenceTimeLimitInMinutes, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        break;
                    case "16":
                        Console.WriteLine("Enter CHANNEL name for PAM Presence Audit");
                        Console.WriteLine("To enter CHANNEL GROUP name, just hit ENTER");
                        channel = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}", channel));
                        Console.ResetColor();
                        Console.WriteLine();

                        if (channel.Trim().Length <= 0)
                        {
                            Console.WriteLine("Enter CHANNEL GROUP name for PAM Presence Audit.");
                            channelGroup = Console.ReadLine();
                            
                            Console.ForegroundColor = ConsoleColor.Blue;
                            Console.WriteLine(string.Format("ChannelGroup = {0}", channelGroup));
                            Console.ResetColor();
                            Console.WriteLine();

                        }
                        if (channel.Trim().Length <= 0 && channelGroup.Trim().Length <= 0)
                        {
                            Console.WriteLine("Channel or ChannelGroup not provided. Please try again.");
                            break;
                        }

                        Console.WriteLine("Enter the auth_key for PAM Presence Audit (optional)");
                        Console.WriteLine("Press Enter Key if there is no auth_key at this time.");
                        string authPresenceAudit = Console.ReadLine();
                        
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("auth_key = {0}", authPresenceAudit));
                        Console.ResetColor();
                        Console.WriteLine();


                        Console.WriteLine("Running PAM Presence Audit()");
                        if (channel.Trim().Length > 0)
                        {
                            pubnub.AuditPresenceAccess<string>(channel, authPresenceAudit, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        else
                        {
                            pubnub.ChannelGroupAuditPresenceAccess<string>(channelGroup, authPresenceAudit, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        break;
                    case "17":
                        Console.WriteLine("Enter CHANNEL name for PAM Presence Revoke");
                        Console.WriteLine("To enter CHANNEL GROUP name, just hit ENTER");
                        channel = Console.ReadLine();

                        if (channel.Trim().Length <= 0)
                        {
                            Console.WriteLine("Enter CHANNEL GROUP name for PAM Revoke.");
                            channelGroup = Console.ReadLine();
                        }
                        if (channel.Trim().Length <= 0 && channelGroup.Trim().Length <= 0)
                        {
                            channel = "";
                            Console.WriteLine("Channel or ChannelGroup not provided. Please try again.");
                            break;
                        }
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}", channel));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("ChannelGroup = {0}", channelGroup));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Enter the auth_key for PAM Presence Revoke (optional)");
                        Console.WriteLine("Press Enter Key if there is no auth_key at this time.");
                        string authPresenceRevoke = Console.ReadLine();
                        
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("auth_key = {0}", authPresenceRevoke));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Running PAM Presence Revoke()");
                        if (channel.Trim().Length > 0)
                        {
                            pubnub.GrantPresenceAccess<string>(channel, authPresenceRevoke, false, false, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        else
                        {
                            pubnub.ChannelGroupGrantPresenceAccess<string>(channelGroup, authPresenceRevoke, false, false, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        break;
                    case "18":
                        Console.WriteLine("Enter Auth Key (applies to all subscribed channels).");
                        Console.WriteLine("If you don't want to use Auth Key, Press ENTER Key");
                        authKey = Console.ReadLine();
                        pubnub.AuthenticationKey = authKey;

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Auth Key = {0}", authKey));
                        Console.ResetColor();
                        Console.WriteLine();

                        break;
                    case "19":
                        Console.WriteLine("Enabling simulation of Sleep/Suspend Mode");  
                        pubnub.EnableMachineSleepModeForTestingOnly();
                        Console.ForegroundColor = ConsoleColor.Red;  
                        Console.WriteLine("Machine Sleep Mode simulation activated");
                        Console.ResetColor();  
                        break;
                    case "20":
                        Console.WriteLine("Disabling simulation of Sleep/Suspend Mode");  
                        pubnub.DisableMachineSleepModeForTestingOnly();
                        Console.ForegroundColor = ConsoleColor.Red;  
                        Console.WriteLine("Simulation going to awake mode");  
                        Console.ResetColor();  
                        break;
                    case "21":
                        Console.WriteLine("Enter Presence Heartbeat in seconds");
                        string pnHeartbeatInput = Console.ReadLine();
                        Int32.TryParse(pnHeartbeatInput, out presenceHeartbeat);
                        pubnub.PresenceHeartbeat = presenceHeartbeat;
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Presence Heartbeat = {0}", presenceHeartbeat));
                        Console.ResetColor();
                        break;
                    case "22":
                        Console.WriteLine("Enter Presence Heartbeat Interval in seconds");
                        Console.WriteLine("NOTE: Ensure that it is less than Presence Heartbeat-3 seconds");
                        string pnHeartbeatIntervalInput = Console.ReadLine();
                        Int32.TryParse(pnHeartbeatIntervalInput, out presenceHeartbeatInterval);
                        pubnub.PresenceHeartbeatInterval = presenceHeartbeatInterval;
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Presence Heartbeat Interval = {0}", presenceHeartbeatInterval));
                        Console.ResetColor();
                        break;
                    case "23":
                        Console.WriteLine("Enter channel name");
                        Console.WriteLine("NOTE: If you want to consider only Channel Group, just hit ENTER");
                        string userStateChannel = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}", userStateChannel));
                        Console.ResetColor();

                        Console.WriteLine("Enter channel group name");
                        Console.WriteLine("NOTE: If you want to consider only Channel, just hit ENTER");
                        string userStateChannelGroup = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("ChannelGroup = {0}", userStateChannelGroup));
                        Console.ResetColor();

                        Console.WriteLine("User State will be accepted as dictionary key:value pair");

                        Console.WriteLine("Enter key. ");
                        string keyUserState = Console.ReadLine();
                        if (string.IsNullOrEmpty(keyUserState.Trim()))
                        {
                            Console.WriteLine("dictionary key:value pair entry completed.");
                            break;
                        }
                        Console.WriteLine("Enter value");
                        string valueUserState = Console.ReadLine();

                        int valueInt;
                        double valueDouble;
                        //string currentUserState = "";
                        if (Int32.TryParse(valueUserState, out valueInt))
                        {
                            pubnub.SetUserState<string>(userStateChannel, userStateChannelGroup, new KeyValuePair<string, object>(keyUserState, valueInt), DisplayReturnMessage, DisplayErrorMessage);
                        }
                        else if (Double.TryParse(valueUserState, out valueDouble))
                        {
                            pubnub.SetUserState<string>(userStateChannel, userStateChannelGroup, new KeyValuePair<string, object>(keyUserState, valueDouble), DisplayReturnMessage, DisplayErrorMessage);
                        }
                        else
                        {
                            pubnub.SetUserState<string>(userStateChannel, userStateChannelGroup, new KeyValuePair<string, object>(keyUserState, valueUserState), DisplayReturnMessage, DisplayErrorMessage);
                        }

                        break;
                    case "24":
                        Console.WriteLine("Enter channel name");
                        Console.WriteLine("NOTE: If you want to consider only Channel Group, just hit ENTER");
                        string deleteChannelUserState = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}", deleteChannelUserState));
                        Console.ResetColor();

                        Console.WriteLine("Enter channel group name");
                        Console.WriteLine("NOTE: If you want to consider only Channel, just hit ENTER");
                        string deleteChannelGroupUserState = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("ChannelGroup = {0}", deleteChannelGroupUserState));
                        Console.ResetColor();

                        Console.WriteLine("Enter key of the User State Key-Value pair to be deleted");
                        string deleteKeyUserState = Console.ReadLine();
                        pubnub.SetUserState<string>(deleteChannelUserState, deleteChannelGroupUserState, new KeyValuePair<string, object>(deleteKeyUserState, null), DisplayReturnMessage, DisplayErrorMessage);

                        break;
                    case "25":
                        Console.WriteLine("Enter channel name");
                        Console.WriteLine("NOTE: If you want to consider only Channel Group, just hit ENTER");
                        string setUserStateChannel = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}", setUserStateChannel));
                        Console.ResetColor();

                        Console.WriteLine("Enter channel group name");
                        Console.WriteLine("NOTE: If you want to consider only Channel, just hit ENTER");
                        string setUserStateChannelGroup = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("ChannelGroup = {0}", setUserStateChannelGroup));
                        Console.ResetColor();

                        Console.WriteLine("Enter user state in json format (Eg. {\"key1\":\"value1\",\"key2\":\"value2\"}");
                        string jsonUserState = Console.ReadLine();

                        if (jsonUserState.Trim() == "")
                        {
                            Console.WriteLine("Invalid User State");
                            break;
                        }
                        Console.WriteLine("Enter UUID. (Optional. Press ENTER to skip it)");
                        string uuid = Console.ReadLine();
                        if (string.IsNullOrEmpty(uuid))
                        {
                            pubnub.SetUserState<string>(setUserStateChannel, setUserStateChannelGroup, jsonUserState, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        else
                        {
                            pubnub.SetUserState<string>(setUserStateChannel, setUserStateChannelGroup, uuid, jsonUserState, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        break;
                    case "26":
                        Console.WriteLine("Enter channel name");
                        Console.WriteLine("NOTE: If you want to consider only Channel Group, just hit ENTER");
                        string getUserStateChannel2 = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}", getUserStateChannel2));
                        Console.ResetColor();

                        Console.WriteLine("Enter channel group name");
                        Console.WriteLine("NOTE: If you want to consider only Channel, just hit ENTER");
                        string setUserStateChannelGroup2 = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("ChannelGroup = {0}", setUserStateChannelGroup2));
                        Console.ResetColor();

                        Console.WriteLine("Enter UUID. (Optional. Press ENTER to skip it)");
                        string uuid2 = Console.ReadLine();
                        if (string.IsNullOrEmpty(uuid2))
                        {
                            pubnub.GetUserState<string>(getUserStateChannel2, setUserStateChannelGroup2, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        else
                        {
                            pubnub.GetUserState<string>(getUserStateChannel2, setUserStateChannelGroup2, uuid2, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        break;
                    case "27":
                        Console.WriteLine("Enter uuid for WhereNow. To consider SessionUUID, just press ENTER");
                        string whereNowUuid = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("uuid = {0}", whereNowUuid));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Running Where_Now()");
                        pubnub.WhereNow<string>(whereNowUuid, DisplayReturnMessage, DisplayErrorMessage);
                        break;
                    case "28":
                        bool globalHereNowShowUUID = true;
                        bool globalHereNowIncludeUserState = false;

                        Console.WriteLine("Show UUID List? Y or N? Default is Y. Press N for No Else press ENTER");
                        string userChoiceGlobalHereNowShowUUID = Console.ReadLine();
                        if (userChoiceGlobalHereNowShowUUID.ToLower() == "n")
                        {
                            globalHereNowShowUUID = false;
                        }
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Show UUID = {0}", globalHereNowShowUUID));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Include User State? Y or N? Default is N. Press Y for Yes Else press ENTER");
                        string userChoiceGlobalHereNowIncludeUserState = Console.ReadLine();
                        if (userChoiceGlobalHereNowIncludeUserState.ToLower() == "y")
                        {
                            globalHereNowIncludeUserState = true;
                        }
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Include User State = {0}", globalHereNowIncludeUserState));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Running Global HereNow()");
                        pubnub.GlobalHereNow<string>(globalHereNowShowUUID, globalHereNowIncludeUserState,DisplayReturnMessage, DisplayErrorMessage);
                        break;
                    case "29":
                        Console.WriteLine("ENTER UUID.");
                        string sessionUUID = Console.ReadLine();
                        pubnub.ChangeUUID(sessionUUID);
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine("UUID = {0}",pubnub.SessionUUID);
                        Console.ResetColor();
                        break;
                    case "38":
                        Console.WriteLine("Enter namespace");
                        string addChannelGroupNamespace = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("namespace = {0}", addChannelGroupNamespace));
                        Console.ResetColor();
                        
                        Console.WriteLine("Enter channel group name");
                        string addChannelGroupName = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("channel group name = {0}", addChannelGroupName));
                        Console.ResetColor();
                        

                        Console.WriteLine("Enter CHANNEL name. Use comma to enter multiple channels.");
                        channel = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}",channel));
                        Console.ResetColor();
                        Console.WriteLine();
                        pubnub.AddChannelsToChannelGroup<string>(channel.Split(','), addChannelGroupNamespace, addChannelGroupName, DisplayReturnMessage, DisplayErrorMessage);
                        break;
                    case "39":
                        Console.WriteLine("Enter namespace");
                        string removeChannelGroupNamespace = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("namespace = {0}", removeChannelGroupNamespace));
                        Console.ResetColor();

                        if (removeChannelGroupNamespace.Trim().Length > 0)
                        {
                            Console.WriteLine("Do you want to remove the namespace and all its group names and all its channels? Default is No. Enter Y for Yes, Else just hit ENTER key");
                            string removeExistingNamespace = Console.ReadLine();
                            if (removeExistingNamespace.ToLower() == "y")
                            {
                                pubnub.RemoveChannelGroupNameSpace<string>(removeChannelGroupNamespace, DisplayReturnMessage, DisplayErrorMessage);
                                break;
                            }
                        }

                        Console.WriteLine("Enter channel group name");
                        string removeChannelGroupName = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("channel group name = {0}", removeChannelGroupName));
                        Console.ResetColor();

                        if (removeChannelGroupName.Trim().Length <= 0)
                        {
                            Console.WriteLine("Channel group not provided. Try again");
                            break;
                        }
                        Console.WriteLine("Do you want to remove the channel group and all its channels? Default is No. Enter Y for Yes, Else just hit ENTER key");
                        string removeExistingGroup = Console.ReadLine();
                        if (removeExistingGroup.ToLower() == "y")
                        {
                            pubnub.RemoveChannelGroup<string>(removeChannelGroupNamespace, removeChannelGroupName, DisplayReturnMessage, DisplayErrorMessage);
                            break;
                        }
                        
                        Console.WriteLine("Enter CHANNEL name. Use comma to enter multiple channels.");
                        channel = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}",channel));
                        Console.ResetColor();
                        Console.WriteLine();
                        pubnub.RemoveChannelsFromChannelGroup<string>(channel.Split(','), removeChannelGroupNamespace, removeChannelGroupName, DisplayReturnMessage, DisplayErrorMessage);
                        break;
                    case "40":
                        Console.WriteLine("Do you want to get all existing namespaces? Default is No. Enter Y for Yes, Else just hit ENTER key");
                        string getExistingNamespace = Console.ReadLine();
                        if (getExistingNamespace.ToLower() == "y")
                        {
                            pubnub.GetAllChannelGroupNamespaces<string>(DisplayReturnMessage, DisplayErrorMessage);
                            break;
                        }

                        Console.WriteLine("Enter namespace");
                        string channelGroupNamespace = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("namespace = {0}", channelGroupNamespace));
                        Console.ResetColor();

                        if (channelGroupNamespace.Trim().Length > 0)
                        {
                            Console.WriteLine("Do you want to get all existing channel group names for the provided namespace? Default is No. Enter Y for Yes, Else just hit ENTER key");
                            string getExistingGroupNames = Console.ReadLine();
                            if (getExistingGroupNames.ToLower() == "y")
                            {
                                pubnub.GetAllChannelGroups<string>(channelGroupNamespace, DisplayReturnMessage, DisplayErrorMessage);
                                break;
                            }
                        }
                        else
                        {
                            Console.WriteLine("Do you want to get all existing channel group names? Default is No. Enter Y for Yes, Else just hit ENTER key");
                            string getExistingGroupNames = Console.ReadLine();
                            if (getExistingGroupNames.ToLower() == "y")
                            {
                                pubnub.GetAllChannelGroups<string>(DisplayReturnMessage, DisplayErrorMessage);
                                break;
                            }
                        }
                        
                        Console.WriteLine("Enter channel group name");
                        string channelGroupName = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("channel group name = {0}", channelGroupName));
                        Console.ResetColor();

                        pubnub.GetChannelsForChannelGroup<string>(channelGroupNamespace, channelGroupName, DisplayReturnMessage, DisplayErrorMessage);
                        break;
                    default:
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("INVALID CHOICE. ENTER 99 FOR EXIT OR QUIT");
                        Console.ResetColor();
                        break;
                }
                if (!exitFlag)
                {
                    userinput = Console.ReadLine();
                    Int32.TryParse(userinput, out currentUserChoice);
                }
            }

            Console.WriteLine("\nPress any key to exit.\n\n");
            Console.ReadLine();

        }
コード例 #19
0
ファイル: PubnubDemo.cs プロジェクト: zhuxuland/c-sharp
 private void btnWhereNow_Click(object sender, EventArgs e)
 {
     UpdateListBoxForDisplay("Running WhereNow");
     pubnub.WhereNow <string>(this.SessionUUID, DisplayReturnMessage, DisplayErrorMessage);
 }
コード例 #20
0
        void ProcessPubnubRequest(string requestType)
        {
            CheckUserInputs();
            channel      = txtChannel.Text;
            channelGroup = txtChannelGroup.Text.Trim();

            bool   storeInHistory = chkStoreInHistory.Checked;
            string pamAuthKey     = txtPAMAuthKey.Text.Trim();

            UpdateTimer.Enabled = true;

            switch (requestType.ToLower())
            {
            case "presence":
                if (channelGroup == "")
                {
                    pubnub.Presence <string>(channel, DisplayUserCallbackMessage, DisplayConnectCallbackMessage, DisplayErrorMessage);
                }
                else
                {
                    pubnub.Presence <string>(channel, channelGroup, DisplayUserCallbackMessage, DisplayConnectCallbackMessage, DisplayErrorMessage);
                }
                break;

            case "subscribe":
                if (channelGroup == "")
                {
                    pubnub.Subscribe <string>(channel, DisplayUserCallbackMessage, DisplayConnectCallbackMessage, DisplayErrorMessage);
                }
                else
                {
                    pubnub.Subscribe <string>(channel, channelGroup, DisplayUserCallbackMessage, DisplayConnectCallbackMessage, DisplayErrorMessage);
                }
                break;

            case "detailedhistory":
                pubnub.DetailedHistory <string>(channel, 10, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "publish":
                if (radNormalPublish.Checked)
                {
                    string messageToBePublished = txtPublishMessage.Text;
                    pubnub.Publish <string>(channel, messageToBePublished, storeInHistory, DisplayUserCallbackMessage, DisplayErrorMessage);
                }
                else if (radToastPublish.Checked)
                {
                    MpnsToastNotification toast = new MpnsToastNotification();
                    //toast.type = "toast";
                    toast.text1 = "hardcode message";
                    Dictionary <string, object> dicToast = new Dictionary <string, object>();
                    dicToast.Add("pn_mpns", toast);

                    pubnub.EnableDebugForPushPublish = true;
                    pubnub.Publish <string>(channel, dicToast, DisplayUserCallbackMessage, DisplayErrorMessage);
                }
                else if (radFlipTilePublish.Checked)
                {
                    pubnub.PushRemoteImageDomainUri.Add(new Uri("http://cdn.flaticon.com"));

                    MpnsFlipTileNotification tile = new MpnsFlipTileNotification();
                    tile.title                 = "front title";
                    tile.count                 = 6;
                    tile.back_title            = "back title";
                    tile.back_content          = "back message";
                    tile.back_background_image = "Assets/Tiles/pubnub3.png";
                    tile.background_image      = "http://cdn.flaticon.com/png/256/37985.png";
                    Dictionary <string, object> dicTile = new Dictionary <string, object>();
                    dicTile.Add("pn_mpns", tile);

                    pubnub.EnableDebugForPushPublish = true;
                    pubnub.Publish <string>(channel, dicTile, DisplayUserCallbackMessage, DisplayErrorMessage);
                }
                else if (radCycleTilePublish.Checked)
                {
                    MpnsCycleTileNotification tile = new MpnsCycleTileNotification();
                    tile.title  = "front title";
                    tile.count  = 2;
                    tile.images = new string[] { "Assets/Tiles/pubnub1.png", "Assets/Tiles/pubnub2.png", "Assets/Tiles/pubnub3.png", "Assets/Tiles/pubnub4.png" };

                    Dictionary <string, object> dicTile = new Dictionary <string, object>();
                    dicTile.Add("pn_mpns", tile);

                    pubnub.EnableDebugForPushPublish = true;
                    pubnub.Publish <string>(channel, dicTile, DisplayUserCallbackMessage, DisplayErrorMessage);
                }
                else if (radIconicTilePublish.Checked)
                {
                    MpnsIconicTileNotification tile = new MpnsIconicTileNotification();
                    tile.title          = "front title";
                    tile.count          = 2;
                    tile.wide_content_1 = "my wide content";

                    Dictionary <string, object> dicTile = new Dictionary <string, object>();
                    dicTile.Add("pn_mpns", tile);

                    pubnub.EnableDebugForPushPublish = true;
                    pubnub.Publish <string>(channel, dicTile, DisplayUserCallbackMessage, DisplayErrorMessage);
                }
                txtPublishMessage.Text = "";
                lblErrorMessage.Text   = "";
                break;

            case "unsubscribe":
                if (channelGroup == "")
                {
                    pubnub.Unsubscribe <string>(channel, DisplayUserCallbackMessage, DisplayConnectCallbackMessage, DisplayDisconnectCallbackMessage, DisplayErrorMessage);
                }
                else
                {
                    pubnub.Unsubscribe <string>(channel, channelGroup, DisplayUserCallbackMessage, DisplayConnectCallbackMessage, DisplayDisconnectCallbackMessage, DisplayErrorMessage);
                }
                break;

            case "presenceunsubscribe":
                if (channelGroup == "")
                {
                    pubnub.PresenceUnsubscribe <string>(channel, DisplayUserCallbackMessage, DisplayConnectCallbackMessage, DisplayDisconnectCallbackMessage, DisplayErrorMessage);
                }
                else
                {
                    pubnub.PresenceUnsubscribe <string>(channel, channelGroup, DisplayUserCallbackMessage, DisplayConnectCallbackMessage, DisplayDisconnectCallbackMessage, DisplayErrorMessage);
                }
                break;

            case "herenow":
                bool showUUID2         = chbShowUUIDList2.Checked;
                bool includeUserState2 = chbShowUserState2.Checked;
                pubnub.HereNow <string>(channel, showUUID2, includeUserState2, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "globalherenow":
                bool showUUID         = chbShowUUIDList.Checked;
                bool includeUserState = chbShowUserState.Checked;
                pubnub.GlobalHereNow <string>(showUUID, includeUserState, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "wherenow":
                pubnub.WhereNow <string>(uuid, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "time":
                pubnub.Time <string>(DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "grantaccess":
                pubnub.GrantAccess <string>(channel, pamAuthKey, true, true, 60, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "revokeaccess":
                pubnub.GrantAccess <string>(channel, pamAuthKey, false, false, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "auditaccess":
                pubnub.AuditAccess <string>(channel, pamAuthKey, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "disablenetwork":
                pubnub.EnableSimulateNetworkFailForTestingOnly();
                break;

            case "enablenetwork":
                pubnub.DisableSimulateNetworkFailForTestingOnly();
                break;

            case "disconnectandretry":
                pubnub.TerminateCurrentSubscriberRequest();
                break;

            case "getuserstate":
                string getUserStateUUID = txtGetUserStateUUID.Text;
                pubnub.GetUserState <string>(channel, getUserStateUUID, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "jsonsetuserstate":
                string jsonUserState = txtJsonUserState.Text;
                pubnub.SetUserState <string>(channel, jsonUserState, DisplayUserCallbackMessage, DisplayErrorMessage);
                break;

            case "setuserstate":
                string key1   = txtKey1.Text;
                string value1 = txtValue1.Text;

                int    valueInt;
                double valueDouble;

                if (Int32.TryParse(value1, out valueInt))
                {
                    pubnub.SetUserState <string>(channel, new KeyValuePair <string, object>(key1, valueInt), DisplayUserCallbackMessage, DisplayErrorMessage);
                }
                else if (Double.TryParse(value1, out valueDouble))
                {
                    pubnub.SetUserState <string>(channel, new KeyValuePair <string, object>(key1, valueDouble), DisplayUserCallbackMessage, DisplayErrorMessage);
                }
                else
                {
                    pubnub.SetUserState <string>(channel, new KeyValuePair <string, object>(key1, value1), DisplayUserCallbackMessage, DisplayErrorMessage);
                }

                break;

            case "channelgroup":
                string userChannelGroupName = txtChannelGroupName.Text;
                if (radChannelGroupGet.Checked)
                {
                    pubnub.GetChannelsForChannelGroup <string>(userChannelGroupName, DisplayUserCallbackMessage, DisplayErrorMessage);
                }
                else if (radChannelGroupAdd.Checked)
                {
                    string userChannelGroupAddChannel = txtChannelGroupAddChannels.Text;
                    pubnub.AddChannelsToChannelGroup <string>(new string[] { userChannelGroupAddChannel }, userChannelGroupName, DisplayUserCallbackMessage, DisplayErrorMessage);
                }
                else if (radChannelGroupRemove.Checked)
                {
                    string userChannelGroupRemoveChannel = txtChannelGroupRemoveChannels.Text;
                    pubnub.RemoveChannelsFromChannelGroup <string>(new string[] { userChannelGroupRemoveChannel }, userChannelGroupName, DisplayUserCallbackMessage, DisplayErrorMessage);
                }
                else if (radChannelGroupGrant.Checked)
                {
                    pubnub.ChannelGroupGrantAccess <string>(userChannelGroupName, true, true, DisplayUserCallbackMessage, DisplayErrorMessage);
                }
                else if (radChannelGroupAudit.Checked)
                {
                    pubnub.ChannelGroupAuditAccess <string>(userChannelGroupName, DisplayUserCallbackMessage, DisplayErrorMessage);
                }
                else if (radChannelGroupRevoke.Checked)
                {
                    pubnub.ChannelGroupGrantAccess <string>(userChannelGroupName, false, false, DisplayUserCallbackMessage, DisplayErrorMessage);
                }
                break;

            default:
                break;
            }
        }
コード例 #21
0
        void ShowAlertType1(CommonDialogStates cds)
        {
            UIAlertView alert = new UIAlertView();

            alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
            bool   isHeartbeatInterval = false;
            string messageBoxTitle     = "Set";

            if (cds == CommonDialogStates.Auth)
            {
                alert.Title   = "Auth Key";
                alert.Message = "Enter Auth Key";
            }
            else if ((cds == CommonDialogStates.AuditSubscribe) ||
                     (cds == CommonDialogStates.AuditPresence) ||
                     (cds == CommonDialogStates.RevokePresence) ||
                     (cds == CommonDialogStates.RevokeSubscribe))
            {
                alert.Title     = "Auth Key";
                alert.Message   = "Enter Auth Key (Optional)";
                messageBoxTitle = cds.ToString();
            }
            else if (cds == CommonDialogStates.PresenceHeartbeat)
            {
                alert.GetTextField(0).KeyboardType = UIKeyboardType.NumberPad;
                alert.Title   = "Presence Heartbeat";
                alert.Message = "Enter Presence Heartbeat";
            }
            else if (cds == CommonDialogStates.PresenceHeartbeatInterval)
            {
                isHeartbeatInterval = true;
                alert.GetTextField(0).KeyboardType = UIKeyboardType.NumberPad;
                alert.Title   = "Presence Heartbeat Interval";
                alert.Message = "Enter Presence Heartbeat Interval";
            }
            else if (cds == CommonDialogStates.ChangeUuid)
            {
                alert.Title   = "Change UUID";
                alert.Message = "Enter UUID";
            }
            else if (cds == CommonDialogStates.WhereNow)
            {
                alert.Title     = "Where Now";
                alert.Message   = "Enter UUID (optional)";
                messageBoxTitle = "Where Now";
            }

            alert.AddButton(messageBoxTitle);
            alert.AddButton("Cancel");
            alert.Clicked += delegate(object sender, UIButtonEventArgs e) {
                if (e.ButtonIndex == 0)
                {
                    if (alert.GetTextField(0) != null)
                    {
                        string input = alert.GetTextField(0).Text;
                        Channel = newChannels.Text;
                        if (cds == CommonDialogStates.Auth)
                        {
                            InvokeInBackground(() => {
                                pubnub.AuthenticationKey = input;
                            });
                            Display("Auth Key Set");
                        }
                        else if (cds == CommonDialogStates.AuditSubscribe)
                        {
                            Display("Running Subscribe Audit");
                            InvokeInBackground(() => {
                                pubnub.AuditAccess <string> (Channel, input, DisplayReturnMessage, DisplayErrorMessage);
                            });
                        }
                        else if (cds == CommonDialogStates.AuditPresence)
                        {
                            Display("Running Presence Audit");
                            InvokeInBackground(() => {
                                pubnub.AuditPresenceAccess <string> (Channel, input, DisplayReturnMessage, DisplayErrorMessage);
                            });
                        }
                        else if (cds == CommonDialogStates.RevokePresence)
                        {
                            Display("Running Presence Revoke");
                            InvokeInBackground(() => {
                                pubnub.GrantPresenceAccess <string> (Channel, input, false, false, DisplayReturnMessage, DisplayErrorMessage);
                            });
                        }
                        else if (cds == CommonDialogStates.RevokeSubscribe)
                        {
                            Display("Running Subscribe Revoke");
                            InvokeInBackground(() => {
                                pubnub.GrantAccess <string> (Channel, input, false, false, DisplayReturnMessage, DisplayErrorMessage);
                            });
                        }
                        else if ((cds == CommonDialogStates.PresenceHeartbeat) || (cds == CommonDialogStates.PresenceHeartbeatInterval))
                        {
                            int iVal;
                            Int32.TryParse(input, out iVal);
                            if (iVal != 0)
                            {
                                if (isHeartbeatInterval)
                                {
                                    InvokeInBackground(() => {
                                        pubnub.PresenceHeartbeatInterval = iVal;
                                    });
                                    Display(string.Format("Presence Heartbeat Interval set to {0}", pubnub.PresenceHeartbeatInterval));
                                }
                                else
                                {
                                    InvokeInBackground(() => {
                                        pubnub.PresenceHeartbeat = iVal;
                                    });
                                    Display(string.Format("Presence Heartbeat set to {0}", pubnub.PresenceHeartbeat));
                                }
                            }
                            else
                            {
                                Display(string.Format("Value not numeric"));
                            }
                        }
                        else if (cds == CommonDialogStates.ChangeUuid)
                        {
                            InvokeInBackground(() => {
                                pubnub.ChangeUUID(input);
                            });
                            Display(string.Format("UUID set to {0}", pubnub.SessionUUID));
                        }
                        else if (cds == CommonDialogStates.WhereNow)
                        {
                            Display("Running where now");
                            InvokeInBackground(() => {
                                pubnub.WhereNow <string> (input, DisplayReturnMessage, DisplayErrorMessage);
                            });
                        }
                    }
                }
            };
            alert.Show();
        }