protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); /*if (ApplicationContext.Resources.Configuration.ScreenLayout = Android.Content.Res.ScreenLayout.SizeLarge) { SetContentView (Resource.Layout.Mainlarge); } else {*/ //} //Build.VERSION.Sdk SetContentView (Resource.Layout.Main); string strChannelName = Intent.GetStringExtra("Channel"); channel = strChannelName; bool bEnableSSL = Convert.ToBoolean((Intent.GetStringExtra("SslOn"))); string strCipher = (Intent.GetStringExtra("Cipher")); string strSsl= ""; if (bEnableSSL) strSsl = ", SSL"; if (!String.IsNullOrWhiteSpace (strCipher)) { strCipher = ", Cipher"; } string strHead = String.Format ("Channel: {0}{1}{2}", strChannelName, strSsl, strCipher); pubnub = new Pubnub ("demo", "demo", "", strCipher, bEnableSSL); Title = strHead; Button btnSubscribe = FindViewById<Button> (Resource.Id.btnSubscribe); btnSubscribe.Click += delegate {Subscribe();}; Button btnSubscribeConnCallback = FindViewById<Button> (Resource.Id.btnSubscribeConnCallback); btnSubscribeConnCallback.Click += delegate {SubscribeConnCallback();}; Button btnCancel = FindViewById<Button> (Resource.Id.btnCancel); btnCancel.Click += delegate {pubnub.EndPendingRequests();Finish();}; Button btnPresence = FindViewById<Button> (Resource.Id.btnPresence); btnPresence.Click += delegate {Presence();}; Button btnPublish = FindViewById<Button> (Resource.Id.btnPublish); btnPublish.Click += delegate {Publish();}; Button btnHereNow = FindViewById<Button> (Resource.Id.btnHereNow); btnHereNow.Click += delegate {HereNow();}; Button btnDetailedHis = FindViewById<Button> (Resource.Id.btnDetailedHis); btnDetailedHis.Click += delegate {DetailedHistory();}; Button btnTime = FindViewById<Button> (Resource.Id.btnTime); btnTime.Click += delegate {GetTime();}; Button btnUnsub = FindViewById<Button> (Resource.Id.btnUnsub); btnUnsub.Click += delegate {Unsub();}; Button btnUnsubPres = FindViewById<Button> (Resource.Id.btnUnsubPres); btnUnsubPres.Click += delegate {UnsubPresence();}; }
static public void Main() { 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 Channel Name"); channel = Console.ReadLine(); Console.WriteLine(string.Format("Channel = {0}",channel)); Console.WriteLine(); Console.WriteLine("Enable SSL? ENTER Y for Yes, else N"); string enableSSL = Console.ReadLine(); if (enableSSL.Trim().ToLower() == "y") { Console.WriteLine("SSL Enabled"); } else { Console.WriteLine("SSL NOT Enabled"); } 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 cipheryKey = Console.ReadLine(); if (cipheryKey.Trim().Length > 0) { Console.WriteLine("Cipher key provided."); } else { Console.WriteLine("No Cipher key provided"); } Console.WriteLine(); pubnub = new Pubnub("demo", "demo", "", cipheryKey, (enableSSL.Trim().ToLower() == "y") ? true : false); Console.WriteLine("ENTER 1 FOR Subscribe (not implementing connectCallback)"); Console.WriteLine("ENTER 2 FOR Subscribe (implementing connectCallback)"); Console.WriteLine("ENTER 3 FOR Publish"); Console.WriteLine("ENTER 4 FOR Presence"); Console.WriteLine("ENTER 5 FOR Detailed History"); Console.WriteLine("ENTER 6 FOR Here_Now"); Console.WriteLine("ENTER 7 FOR Unsubscribe"); Console.WriteLine("ENTER 8 FOR Presence-Unsubscribe"); Console.WriteLine("ENTER 9 FOR Time"); Console.WriteLine("ENTER 0 FOR EXIT OR QUIT"); bool exitFlag = false; Console.WriteLine(""); while (!exitFlag) { string userinput = Console.ReadLine(); switch (userinput) { case "0": exitFlag = true; pubnub.EndPendingRequests(); break; case "1": Console.WriteLine("Running subscribe() (not implementing connectCallback)"); pubnub.subscribe<string>(channel, DisplayReturnMessage); break; case "2": Console.WriteLine("Running subscribe() (implementing connectCallback)"); pubnub.subscribe<string>(channel, DisplayReturnMessage, DisplayConnectStatusMessage); break; case "3": Console.WriteLine("Running publish()"); Console.WriteLine("Enter the message for publish. To exit loop, enter QUIT"); string publishMsg = Console.ReadLine(); double doubleData; int intData; if (int.TryParse(publishMsg, out intData)) //capture numeric data { pubnub.publish<string>(channel, intData, DisplayReturnMessage); } else if (double.TryParse(publishMsg, out doubleData)) //capture numeric data { pubnub.publish<string>(channel, doubleData, DisplayReturnMessage); } 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); } else if (double.TryParse(strMsg, out doubleData)) { pubnub.publish<string>(channel, strMsg, DisplayReturnMessage); } else { pubnub.publish<string>(channel, publishMsg, DisplayReturnMessage); } } else { pubnub.publish<string>(channel, publishMsg, DisplayReturnMessage); } } break; case "4": Console.WriteLine("Running presence()"); pubnub.presence<string>(channel, DisplayReturnMessage); break; case "5": Console.WriteLine("Running detailed history()"); pubnub.detailedHistory<string>(channel, 100, DisplayReturnMessage); break; case "6": Console.WriteLine("Running Here_Now()"); pubnub.here_now<string>(channel, DisplayReturnMessage); break; case "7": Console.WriteLine("Running unsubscribe()"); pubnub.unsubscribe<string>(channel, DisplayReturnMessage); break; case "8": Console.WriteLine("Running presence-unsubscribe()"); pubnub.presence_unsubscribe<string>(channel, DisplayReturnMessage); break; case "9": Console.WriteLine("Running time()"); pubnub.time<string>(DisplayReturnMessage); break; default: Console.WriteLine("INVALID CHOICE."); break; } } Console.WriteLine("\nPress any key to exit.\n\n"); Console.ReadLine(); }
static public void Main() { 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 Channel Name"); channel = Console.ReadLine(); Console.WriteLine(string.Format("Channel = {0}", channel)); Console.WriteLine(); Console.WriteLine("Enable SSL? ENTER Y for Yes, else N"); string enableSSL = Console.ReadLine(); if (enableSSL.Trim().ToLower() == "y") { Console.WriteLine("SSL Enabled"); } else { Console.WriteLine("SSL NOT Enabled"); } 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 cipheryKey = Console.ReadLine(); if (cipheryKey.Trim().Length > 0) { Console.WriteLine("Cipher key provided."); } else { Console.WriteLine("No Cipher key provided"); } Console.WriteLine(); pubnub = new Pubnub("demo", "demo", "", cipheryKey, (enableSSL.Trim().ToLower() == "y") ? true : false); Console.WriteLine("ENTER 1 FOR Subscribe (not implementing connectCallback)"); Console.WriteLine("ENTER 2 FOR Subscribe (implementing connectCallback)"); Console.WriteLine("ENTER 3 FOR Publish"); Console.WriteLine("ENTER 4 FOR Presence"); Console.WriteLine("ENTER 5 FOR Detailed History"); Console.WriteLine("ENTER 6 FOR Here_Now"); Console.WriteLine("ENTER 7 FOR Unsubscribe"); Console.WriteLine("ENTER 8 FOR Presence-Unsubscribe"); Console.WriteLine("ENTER 9 FOR Time"); Console.WriteLine("ENTER 0 FOR EXIT OR QUIT"); bool exitFlag = false; Console.WriteLine(""); while (!exitFlag) { string userinput = Console.ReadLine(); switch (userinput) { case "0": exitFlag = true; pubnub.EndPendingRequests(); break; case "1": Console.WriteLine("Running subscribe() (not implementing connectCallback)"); pubnub.subscribe <string>(channel, DisplayReturnMessage); break; case "2": Console.WriteLine("Running subscribe() (implementing connectCallback)"); pubnub.subscribe <string>(channel, DisplayReturnMessage, DisplayConnectStatusMessage); break; case "3": Console.WriteLine("Running publish()"); Console.WriteLine("Enter the message for publish. To exit loop, enter QUIT"); string publishMsg = Console.ReadLine(); double doubleData; int intData; if (int.TryParse(publishMsg, out intData)) //capture numeric data { pubnub.publish <string>(channel, intData, DisplayReturnMessage); } else if (double.TryParse(publishMsg, out doubleData)) //capture numeric data { pubnub.publish <string>(channel, doubleData, DisplayReturnMessage); } 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); } else if (double.TryParse(strMsg, out doubleData)) { pubnub.publish <string>(channel, strMsg, DisplayReturnMessage); } else { pubnub.publish <string>(channel, publishMsg, DisplayReturnMessage); } } else { pubnub.publish <string>(channel, publishMsg, DisplayReturnMessage); } } break; case "4": Console.WriteLine("Running presence()"); pubnub.presence <string>(channel, DisplayReturnMessage); break; case "5": Console.WriteLine("Running detailed history()"); pubnub.detailedHistory <string>(channel, 100, DisplayReturnMessage); break; case "6": Console.WriteLine("Running Here_Now()"); pubnub.here_now <string>(channel, DisplayReturnMessage); break; case "7": Console.WriteLine("Running unsubscribe()"); pubnub.unsubscribe <string>(channel, DisplayReturnMessage); break; case "8": Console.WriteLine("Running presence-unsubscribe()"); pubnub.presence_unsubscribe <string>(channel, DisplayReturnMessage); break; case "9": Console.WriteLine("Running time()"); pubnub.time <string>(DisplayReturnMessage); break; default: Console.WriteLine("INVALID CHOICE."); break; } } Console.WriteLine("\nPress any key to exit.\n\n"); Console.ReadLine(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); /*if (ApplicationContext.Resources.Configuration.ScreenLayout = Android.Content.Res.ScreenLayout.SizeLarge) { * SetContentView (Resource.Layout.Mainlarge); * } else {*/ //} //Build.VERSION.Sdk SetContentView(Resource.Layout.Main); string strChannelName = Intent.GetStringExtra("Channel"); channel = strChannelName; bool bEnableSSL = Convert.ToBoolean((Intent.GetStringExtra("SslOn"))); string strCipher = (Intent.GetStringExtra("Cipher")); string strSsl = ""; if (bEnableSSL) { strSsl = ", SSL"; } if (!String.IsNullOrWhiteSpace(strCipher)) { strCipher = ", Cipher"; } string strHead = String.Format("Channel: {0}{1}{2}", strChannelName, strSsl, strCipher); pubnub = new Pubnub("demo", "demo", "", strCipher, bEnableSSL); Title = strHead; Button btnSubscribe = FindViewById <Button> (Resource.Id.btnSubscribe); btnSubscribe.Click += delegate { Subscribe(); }; Button btnSubscribeConnCallback = FindViewById <Button> (Resource.Id.btnSubscribeConnCallback); btnSubscribeConnCallback.Click += delegate { SubscribeConnCallback(); }; Button btnCancel = FindViewById <Button> (Resource.Id.btnCancel); btnCancel.Click += delegate { pubnub.EndPendingRequests(); Finish(); }; Button btnPresence = FindViewById <Button> (Resource.Id.btnPresence); btnPresence.Click += delegate { Presence(); }; Button btnPublish = FindViewById <Button> (Resource.Id.btnPublish); btnPublish.Click += delegate { Publish(); }; Button btnHereNow = FindViewById <Button> (Resource.Id.btnHereNow); btnHereNow.Click += delegate { HereNow(); }; Button btnDetailedHis = FindViewById <Button> (Resource.Id.btnDetailedHis); btnDetailedHis.Click += delegate { DetailedHistory(); }; Button btnTime = FindViewById <Button> (Resource.Id.btnTime); btnTime.Click += delegate { GetTime(); }; Button btnUnsub = FindViewById <Button> (Resource.Id.btnUnsub); btnUnsub.Click += delegate { Unsub(); }; Button btnUnsubPres = FindViewById <Button> (Resource.Id.btnUnsubPres); btnUnsubPres.Click += delegate { UnsubPresence(); }; }
public Pubnub_MessagingSub (string strChannelName, string strCipher, bool bEnableSSL) : base (UITableViewStyle.Grouped, null) { _Channel = strChannelName; _Ssl = bEnableSSL; _Cipher = strCipher; string strSsl = ""; if (_Ssl) { strSsl = ", SSL"; } string strCip = ""; if (!String.IsNullOrWhiteSpace (_Cipher)) { strCip = ", Cipher"; } string strHead = String.Format ("Ch: {0} {1} {2}", _Channel, strSsl, strCip); _pubnub = new Pubnub ("demo", "demo", "", _Cipher, _Ssl); Section secAction = new Section (); bool bIphone = true; string strHardwareVer = DeviceHardware.Version.ToString ().ToLower (); if (strHardwareVer.IndexOf ("ipad") >= 0) { bIphone = false; } Dictionary<string, RectangleF> dictRect = null; int iViewHeight = 140; if (bIphone) { dictRect = GetRectanglesForIphone(); iViewHeight = 140; } else { dictRect = GetRectanglesForIpad(); iViewHeight = 85; } secAction.HeaderView = CreateHeaderView(dictRect, iViewHeight); _secOutput = new Section("Output"); _root = new RootElement (strHead) { secAction, _secOutput }; Root = _root; _dvc = new DialogViewController (_root, true); _dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, delegate { _pubnub.EndPendingRequests (); AppDelegate.navigation.PopToRootViewController(true); }); AppDelegate.navigation.PushViewController (_dvc, true); }