Permalink
Browse files

updated the code in Mono-for-mac and Mono-for-linux

  • Loading branch information...
1 parent 717933a commit cab441be1ce1084e41854a8733e7a731a7e2f643 @crimsonred crimsonred committed Dec 9, 2012
Showing with 0 additions and 10,196 deletions.
  1. +0 −82 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/DetailedHistory_Example.cs
  2. +0 −39 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/Here_Now_Example.cs
  3. +0 −74 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/PresenceUnsubscribe_Example.cs
  4. +0 −157 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/Presence_Example.cs
  5. +0 −213 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/PubNub-Example.cs
  6. +0 −796 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/PubNub-Example2.cs
  7. +0 −114 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/Publish_Example.cs
  8. +0 −2,925 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/PubnubBase.cs
  9. +0 −21 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/PubnubExtend.cs
  10. +0 −226 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/Subscribe_Example.cs
  11. +0 −82 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/DetailedHistory_Example.cs
  12. +0 −39 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/Here_Now_Example.cs
  13. +0 −75 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/Main.cs
  14. +0 −74 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/PresenceUnsubscribe_Example.cs
  15. +0 −157 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/Presence_Example.cs
  16. +0 −65 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/PubNub-Console.csproj
  17. +0 −213 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/PubNub-Example.cs
  18. +0 −796 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/PubNub-Example2.cs
  19. +0 −114 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/Publish_Example.cs
  20. +0 −2,925 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/PubnubBase.cs
  21. +0 −21 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/PubnubExtend.cs
  22. +0 −226 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/Subscribe_Example.cs
  23. BIN mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/bin/Debug/Newtonsoft.Json.dll
  24. BIN mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/bin/Debug/PubNub-Messaging.exe
  25. +0 −16 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/bin/Debug/PubNub-Messaging.exe.config
  26. BIN mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/bin/Debug/PubNub-Messaging.exe.mdb
  27. +0 −69 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/bin/Debug/pubnub-messaging.log
  28. BIN mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/bin/Debug/Newtonsoft.Json.dll
  29. BIN mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/bin/Debug/PubNub-Messaging.exe
  30. +0 −16 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/bin/Debug/PubNub-Messaging.exe.config
  31. BIN mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/bin/Debug/PubNub-Messaging.exe.mdb
  32. BIN mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/bin/Debug/PubNubTest.dll
  33. +0 −16 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/bin/Debug/PubNubTest.dll.config
  34. BIN mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/bin/Debug/PubNubTest.dll.mdb
  35. +0 −17 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/bin/Debug/pubnub-messaging.log
  36. +0 −628 ...3.0.1/PubNub-Messaging/PubNubTest/test-results/PubNub-Messaging.Tests.csproj-Debug-2012-11-27.xml
  37. BIN ...for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/test-results/PubNub-Messaging.Tests.csproj.test-cache
View
82 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/DetailedHistory_Example.cs
@@ -1,82 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace PubNub_Messaging
-{
- internal static class DetailedHistory_Example
- {
- /*public static void Main()
- {
- DetailedHistoryCountDemo();
- Console.ReadLine();
- }*/
-
- internal static void DetailedHistoryCountDemo()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "",
- false);
-
- string channel = "my_channel";
-
- //Console.WriteLine("Detailed History Count Demo");
- //pubnub.detailedHistory(channel, 100, DisplayDetailedHistory);
-
- //Console.WriteLine("Detailed History Count and reverse Demo");
- //pubnub.detailedHistory(channel, -1, -1, 100, true, DisplayDetailedHistory);
-
- //Console.WriteLine("Detailed History with start and end");
- //pubnub.detailedHistory(channel, 13499635513028988, 13499836911845528, 200, true, DisplayDetailedHistory);
-
- //Console.WriteLine("Detailed History with start");
- //pubnub.detailedHistory(channel, 13499635513028988, -1, 100, true, DisplayDetailedHistory);
-
- Console.WriteLine("Detailed History with end");
- pubnub.detailedHistory(channel, -1, 13499836911845528, 100, true, DisplayDetailedHistory);
- }
-
- static void DisplayDetailedHistory(object result)
- {
- try
- {
- IList<object> msg = result as IList<object>;
- if (msg != null && msg.Count > 0)
- {
- object[] history = msg[0] as object[];
- if (history != null && history.Length > 0)
- {
- Console.WriteLine(string.Format("Total history records = {0}", history.Length));
- foreach (object item in history)
- {
- if (!item.GetType().IsGenericType)
- {
- Console.WriteLine(item.ToString());
- }
- else if ((item.GetType().IsGenericType) && (item.GetType().Name == typeof(Dictionary<,>).Name))
- {
- Dictionary<string, object> itemList = (Dictionary<string, object>)item;
- foreach (KeyValuePair<string, object> pair in itemList)
- {
- Console.WriteLine(string.Format("Key = {0}; Value = {1}", pair.Key, pair.Value));
- }
- }
- else
- {
- Console.WriteLine(string.Format("Unhandled type {0}",item.ToString()));
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.ToString());
- }
- }
- }
-}
View
39 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/Here_Now_Example.cs
@@ -1,39 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace PubNub_Messaging
-{
- internal static class Here_Now_Example
- {
- /*public static void Main()
- {
- Here_Now_Demo();
- Console.ReadLine();
- }*/
-
- internal static void Here_Now_Demo()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "",
- false);
-
- string channel = "my/channel";
-
- Console.WriteLine("Here_Now_Example");
-
- pubnub.here_now<string>(channel, DisplayReturnMessage);
-
- }
-
- static void DisplayReturnMessage(string result )
- {
- Console.WriteLine(result);
- }
-
- }
-}
View
74 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/PresenceUnsubscribe_Example.cs
@@ -1,74 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace PubNub_Messaging
-{
- internal class PresenceUnsubscribe_Example
- {
- internal static void PresenceUnsubscribeDemo()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "",
- false);
-
- string channel = "my_channel";
-
- Console.WriteLine("PresenceUnsubscribe_Example");
-
- pubnub.presence_unsubscribe(channel, DisplayPresenceUnpresenceReturnMessage);
-
- }
-
- static void DisplayPresenceUnpresenceReturnMessage(object result)
- {
- IList<object> message = result as IList<object>;
-
- if (message != null && message.Count >= 2)
- {
- for(int index=0; index < message.Count; index++)
- {
- Console.WriteLine(string.Format("[{0}] = {1}",index, message[index].ToString()));
- object[] msg = message[0] as object[];
- if (msg != null)
- {
- foreach (object item in msg)
- {
- if (item is Dictionary<string, object>)
- {
- Dictionary<string, object> itemList = (Dictionary<string, object>)item;
- foreach (KeyValuePair<string, object> pair in itemList)
- {
- Console.WriteLine(string.Format("Key = {0}; Value = {1}", pair.Key, pair.Value));
- }
- }
- else if (item is object[])
- {
- object[] itemList = (object[])item;
- foreach (string innerItem in itemList)
- {
- Console.WriteLine(innerItem.ToString());
- }
- }
- else
- {
- Console.WriteLine(item.ToString());
- }
- }
- }
- }
- Console.WriteLine(string.Format("Channel = {0}", message[2].ToString()));
-
- }
- else
- {
- Console.WriteLine("result is not List<object>");
- }
- }
-
- }
-}
View
157 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/Presence_Example.cs
@@ -1,157 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace PubNub_Messaging
-{
- internal static class Presence_Example
- {
- internal static void PresenceDemo()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "",
- false);
-
- string channel = "my_channel";
-
- Console.WriteLine("Presence_Example");
-
- pubnub.presence(channel, DisplayReturnMessage);
-
- bool pre_unsub = false;
- while (!pre_unsub)
- {
- Console.WriteLine("Enter y for Presence-Unsub; x to EXIT presence loop");
- string userchoice = Console.ReadLine();
- if (userchoice.ToLower() == "y")
- {
- Console.WriteLine("PresenceUnsubscribe_Example");
- pubnub.presence_unsubscribe(channel, DisplayReturnMessage);
-
- pre_unsub = true;
- }
- else if (userchoice.ToLower() == "x")
- {
- pre_unsub = true;
- }
- }
-
-
- }
-
- static void DisplayReturnMessage(object result)
- {
- IList<object> message = result as IList<object>;
-
- if (message != null && message.Count >= 2)
- {
- for (int index = 0; index < message.Count; index++)
- {
- ParseObject(message[index], 1);
- }
- }
- else
- {
- Console.WriteLine("unable to parse data");
- }
- }
-
- static void ParseObject(object result, int loop)
- {
- if (result is object[])
- {
- object[] arrResult = (object[])result;
- foreach (object item in arrResult)
- {
- if (!item.GetType().IsGenericType)
- {
- if (!item.GetType().IsArray)
- {
- Console.WriteLine(item.ToString());
- }
- else
- {
- ParseObject(item, loop + 1);
- }
- }
- else
- {
- ParseObject(item, loop + 1);
- }
- }
- }
- else if (result.GetType().IsGenericType && (result.GetType().Name == typeof(Dictionary<,>).Name))
- {
- Dictionary<string, object> itemList = (Dictionary<string, object>)result;
- foreach (KeyValuePair<string, object> pair in itemList)
- {
- Console.WriteLine(string.Format("key = {0}", pair.Key));
- if (pair.Value is object[])
- {
- Console.WriteLine("value = ");
- ParseObject(pair.Value, loop);
- }
- else
- {
- Console.WriteLine(string.Format("value = {0}", pair.Value));
- }
- }
- }
-
- }
-
- //static void DisplayReturnMessage(object result)
- //{
- // IList<object> message = result as IList<object>;
-
- // if (message != null && message.Count >= 2)
- // {
- // for (int index = 0; index < message.Count; index++)
- // {
- // if (!message[index].GetType().IsGenericType)
- // {
- // if (message[index] is object[])
- // {
- // object[] itemList = (object[])message[index];
- // for (int itemIndex = 0; itemIndex < itemList.Length; itemIndex++)
- // {
- // if (!itemList[itemIndex].GetType().IsGenericType)
- // {
- // Console.WriteLine(string.Format("[{0}][{1}] = {2}", index, itemIndex, itemList[itemIndex].ToString()));
- // }
- // else if ((itemList[itemIndex].GetType().IsGenericType) && (itemList[itemIndex].GetType().Name == typeof(Dictionary<,>).Name))
- // {
- // Dictionary<string, object> subitemList = (Dictionary<string, object>)itemList[itemIndex];
- // foreach (KeyValuePair<string, object> pair in subitemList)
- // {
- // Console.WriteLine(string.Format("[{0}][{1}] = {2}", index, pair.Key, pair.Value));
- // }
- // }
- // }
- // }
- // else
- // {
- // Console.WriteLine(string.Format("[{0}] = {1}", index, message[index].ToString()));
- // }
- // }
- // else if ((message[index].GetType().IsGenericType) && (message[index].GetType().Name == typeof(Dictionary<,>).Name))
- // {
- // Dictionary<string, object> itemList = (Dictionary<string, object>)message[index];
- // foreach (KeyValuePair<string, object> pair in itemList)
- // {
- // Console.WriteLine(string.Format("[{0}][{1}] = {2}",index, pair.Key, pair.Value));
- // }
- // }
- // }
- // }
- // else
- // {
- // Console.WriteLine("result is not List<object>");
- // }
- //}
- }
-}
View
213 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/PubNub-Example.cs
@@ -1,213 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.ComponentModel;
-using System.Threading;
-
-namespace PubNub_Messaging
-{
- public class Pubnub_Example
- {
- static public Pubnub pubnub;
-
- static public bool deliveryStatus = false;
- static public string channel = "";
-
- 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");
- 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 0 FOR EXIT OR QUIT");
-
- bool exitFlag = false;
-
- Console.WriteLine("");
- while (!exitFlag)
- {
- string userinput = Console.ReadLine();
- switch (userinput)
- {
- case "0":
- exitFlag = true;
- break;
- case "1":
- Console.WriteLine("Running subscribe()");
- pubnub.subscribe<string>(channel, DisplayReturnMessage);
- //System.Threading.Tasks.Task subtask = System.Threading.Tasks.Task.Factory.StartNew(() => pubnub.subscribe<string>(channel, DisplayReturnMessage));
- //pubnub.subscribe<object>(channel, DisplayReturnMessage);
- //pubnub.subscribe(channel, DisplayReturnMessage);
- break;
- case "2":
- Console.WriteLine("Running publish()");
- Console.WriteLine("Enter the message for publish. To exit loop, enter QUIT");
- string publishMsg = Console.ReadLine();
- pubnub.publish<string>(channel, publishMsg, DisplayReturnMessage);
- break;
- case "3":
- Console.WriteLine("Running presence()");
- pubnub.presence<string>(channel, DisplayReturnMessage);
- //System.Threading.Tasks.Task pretask = System.Threading.Tasks.Task.Factory.StartNew(() => pubnub.presence<string>(channel, DisplayReturnMessage));
- //pubnub.presence<object>(channel, DisplayReturnMessage);
- break;
- case "4":
- Console.WriteLine("Running detailed history()");
- pubnub.detailedHistory<string>(channel, 100, DisplayReturnMessage);
- //pubnub.detailedHistory<object>(channel, 100, DisplayReturnMessage);
- break;
- case "5":
- Console.WriteLine("Running Here_Now()");
- pubnub.here_now<string>(channel, DisplayReturnMessage);
- //pubnub.here_now<object>(channel, DisplayReturnMessage);
- break;
- case "6":
- Console.WriteLine("Running unsubscribe()");
- pubnub.unsubscribe<string>(channel, DisplayReturnMessage);
- //pubnub.unsubscribe<object>(channel, DisplayReturnMessage);
- break;
- case "7":
- Console.WriteLine("Running presence-unsubscribe()");
- pubnub.presence_unsubscribe<string>(channel, DisplayReturnMessage);
- break;
- case "8":
- Console.WriteLine("Running time()");
- pubnub.time<string>(DisplayReturnMessage);
- break;
- default:
- Console.WriteLine("INVALID CHOICE.");
- break;
- }
- }
-
- Console.WriteLine("\nPress any key to confirm exit.\n\n");
- Console.ReadLine();
-
- }
-
- static void DisplayReturnMessage(string result)
- {
- Console.WriteLine(result);
- }
-
- static void DisplayReturnMessage(object result)
- {
- IList<object> message = result as IList<object>;
-
- if (message != null && message.Count >= 1)
- {
- for (int index = 0; index < message.Count; index++)
- {
- ParseObject(message[index], 1);
- }
- }
- else
- {
- Console.WriteLine("unable to parse data");
- }
- }
-
- static void ParseObject(object result, int loop)
- {
- if (result is object[])
- {
- object[] arrResult = (object[])result;
- foreach (object item in arrResult)
- {
- if (item != null)
- {
- if (!item.GetType().IsGenericType)
- {
- if (!item.GetType().IsArray)
- {
- Console.WriteLine(item.ToString());
- }
- else
- {
- ParseObject(item, loop + 1);
- }
- }
- else
- {
- ParseObject(item, loop + 1);
- }
- }
- else
- {
- Console.WriteLine();
- }
- }
- }
- else if (result.GetType().IsGenericType && (result.GetType().Name == typeof(Dictionary<,>).Name))
- {
- Dictionary<string, object> itemList = (Dictionary<string, object>)result;
- foreach (KeyValuePair<string, object> pair in itemList)
- {
- Console.WriteLine(string.Format("key = {0}", pair.Key));
- if (pair.Value is object[])
- {
- Console.WriteLine("value = ");
- ParseObject(pair.Value, loop);
- }
- else
- {
- Console.WriteLine(string.Format("value = {0}", pair.Value));
- }
- }
- }
- else
- {
- Console.WriteLine(result.ToString());
- }
-
- }
-
- }
-}
View
796 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/PubNub-Example2.cs
@@ -1,796 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.ComponentModel;
-using System.Collections;
-
-namespace PubNub_Messaging
-{
- public class Pubnub_Example2
- {
- static public bool deliveryStatus = false;
- static public string channel = "testchannel";
- static public string message = "Pubnub API Usage Example - Publish";
- static public Dictionary<long, string> inputs = new Dictionary<long, string>();
- static public object objResponse = null;
-
- public static void TestEncryptedDetailedHistoryParams()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "enigma",
- false);
- // Context setup for Detailed Histor
- //pubnub.CIPHER_KEY = "enigma";
- int total_msg = 10;
- long starttime = Timestamp(pubnub);
-
- for (int i = 0; i < total_msg / 2; i++)
- {
- deliveryStatus = false;
- string msg = i.ToString();
- pubnub.publish(channel, msg, DisplayReturnMessage);
- while (!deliveryStatus) ;
- //long t = Timestamp();
- //inputs.Add(t, msg);
- Console.WriteLine("Message # " + i.ToString() + " published");
- }
-
- long midtime = Timestamp(pubnub);
- for (int i = total_msg / 2; i < total_msg; i++)
- {
- deliveryStatus = false;
- string msg = i.ToString();
- pubnub.publish(channel, msg, DisplayReturnMessage);
- while (!deliveryStatus) ;
- //long t = Timestamp();
- //inputs.Add(t, msg);
- Console.WriteLine("Message # " + i.ToString() + " published");
- }
-
-
- long endtime = Timestamp(pubnub);
-
- deliveryStatus = false;
- pubnub.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == "DetailedHistory")
- {
- Console.WriteLine("\n*********** DetailedHistory Messages *********** ");
- /*foreach (object msg_org in (List<object>)((Pubnub)sender).DetailedHistory)
- {
- Console.WriteLine(msg_org.ToString());
- }*/
- deliveryStatus = true;
- }
- };
- Console.WriteLine("DetailedHistory with start & end");
- pubnub.detailedHistory(channel, starttime, midtime, total_msg / 2, true, DisplayReturnMessage);
- while (!deliveryStatus) ;
- Console.WriteLine("DetailedHistory with start & reverse = true");
- deliveryStatus = false;
- pubnub.detailedHistory(channel, midtime, -1, total_msg / 2, true, DisplayReturnMessage);
- while (!deliveryStatus) ;
- Console.WriteLine("DetailedHistory with start & reverse = false");
- deliveryStatus = false;
- pubnub.detailedHistory(channel, midtime, -1, total_msg / 2, false, DisplayReturnMessage);
- while (!deliveryStatus) ;
- Console.WriteLine("\n******* DetailedHistory Messages Received ******* ");
- }
-
- public static long Timestamp (Pubnub pubnub)
- {
- deliveryStatus = false;
-
- pubnub.time(DisplayReturnMessage);
- while (!deliveryStatus) ;
- string strResponse = "";
-
- IList<object> fields = objResponse as IList<object>;
- return Convert.ToInt64(fields[0].ToString());
- }
-
- public static void TestUnencryptedHistory()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "",
- false);
- string channel = "testchannel";
- //pubnub.CIPHER_KEY = "";
-
- deliveryStatus = false;
- string message = "Pubnub API Usage Example - Publish";
-
-
- pubnub.publish(channel, message, DisplayReturnMessage);
- while (!deliveryStatus) ;
- pubnub.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) {
- if (e.PropertyName == "History")
- {
- Console.WriteLine("\n*********** History Messages *********** ");
- deliveryStatus = true;
- }
- };
- pubnub.history(channel, 1);
-
- deliveryStatus = false;
-
- while (!deliveryStatus) ;
- Console.WriteLine("\n*********** Publish *********** ");
- if (pubnub.History[0].Equals (null)) {
- Console.WriteLine("Null response");
- }
- else
- {
- Console.WriteLine(pubnub.History[0].ToString());
- }
- }
-
- public static void TestEncryptedHistory()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "enigma",
- false);
- string channel = "testchannel";
-
- deliveryStatus = false;
- string message = "Pubnub API Usage Example - Publish";
-
- pubnub.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == "History")
- {
- Console.WriteLine("\n*********** History Messages *********** ");
- deliveryStatus = true;
- }
- };
- deliveryStatus = false;
- pubnub.publish(channel, message, DisplayReturnMessage);
- while (!deliveryStatus) ;
-
- deliveryStatus = false;
- pubnub.history(channel, 1);
- while (!deliveryStatus) ;
- if (pubnub.History[0].Equals (null)) {
- Console.WriteLine("Null response");
- }
- else
- {
- Console.WriteLine(pubnub.History[0].ToString());
- }
- }
-
- public static void TestUnencryptedDetailedHistory()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "",
- false);
- string channel = "testchannel";
- //pubnub.CIPHER_KEY = "";
- int total_msg = 10;
- long starttime = Timestamp(pubnub);
- Dictionary<long, string> inputs = new Dictionary<long,string>();
- for (int i = 0; i < total_msg / 2; i++)
- {
- deliveryStatus = false;
- string msg = i.ToString();
- pubnub.publish(channel, msg, DisplayReturnMessage);
- while (!deliveryStatus) ;
- //long t = Timestamp();
- //inputs.Add(t, msg);
- Console.WriteLine("Message # " + i.ToString() + " published");
- }
-
- long midtime = Timestamp(pubnub);
- for (int i = total_msg / 2; i < total_msg; i++)
- {
- deliveryStatus = false;
- string msg = i.ToString();
- pubnub.publish(channel, msg, DisplayReturnMessage);
- while (!deliveryStatus) ;
- //long t = Timestamp();
- //inputs.Add(t, msg);
- Console.WriteLine("Message # " + i.ToString() + " published");
- }
-
-
- long endtime = Timestamp(pubnub);
- while (!deliveryStatus) ;
-
- deliveryStatus = false;
- pubnub.detailedHistory(channel, total_msg, DisplayReturnMessage);
- deliveryStatus = false;
- while (!deliveryStatus) ;
-
- Console.WriteLine("\n******* DetailedHistory Messages Received ******* ");
-
- string strResponse = "";
- if (objResponse.Equals(null))
- {
- Console.WriteLine("Null response");
- }
- else
- {
- IList<object> fields =objResponse as IList<object>;
- int j = 0;
- foreach (object item in fields)
- {
- strResponse = item.ToString();
- Console.WriteLine(String.Format("resp:{0} :: j: {1}", strResponse, j));
- if(j<total_msg)
- Console.WriteLine(strResponse);
- j++;
- }
- }
- }
-
- public static void TestEncryptedDetailedHistory()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "enigma",
- false);
- string channel = "testchannel";
- //pubnub.CIPHER_KEY = "enigma";
-
- int total_msg = 10;
- long starttime = Timestamp(pubnub);
- Dictionary<long, string> inputs = new Dictionary<long, string>();
- for (int i = 0; i < total_msg / 2; i++)
- {
- string msg = i.ToString();
- pubnub.publish(channel, msg, DisplayReturnMessage);
- while (!deliveryStatus) ;
- //long t = Timestamp();
- //inputs.Add(t, msg);
- Console.WriteLine("Message # " + i.ToString() + " published");
- }
-
- long midtime = Timestamp(pubnub);
- for (int i = total_msg / 2; i < total_msg; i++)
- {
- string msg = i.ToString();
- pubnub.publish(channel, msg, DisplayReturnMessage);
- while (!deliveryStatus) ;
- //long t = Timestamp();
- //inputs.Add(t, msg);
- Console.WriteLine("Message # " + i.ToString() + " published");
- }
-
- long endtime = Timestamp(pubnub);
- while (!deliveryStatus) ;
-
-
-
- pubnub.detailedHistory(channel, total_msg, DisplayReturnMessage);
- deliveryStatus = false;
- while (!deliveryStatus) ;
- Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");
- string strResponse = "";
- if (objResponse.Equals(null))
- {
- Console.WriteLine("Null response");
- }
- else
- {
- IList<object> fields = objResponse as IList<object>;
- int j = 0;
- foreach (object item in fields)
- {
- strResponse = item.ToString();
- Console.WriteLine(String.Format("resp:{0} :: j: {1}", strResponse, j));
- if(j<total_msg)
- Console.WriteLine(j.ToString(), strResponse);
- j++;
- }
- }
- Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");
- }
-
- public static void TestUnencryptedDetailedHistoryParams()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "",
- false);
- string channel = "testchannel";
-
- int total_msg = 10;
- long starttime = Timestamp(pubnub);
-
-
- for (int i = 0; i < total_msg / 2; i++)
- {
- deliveryStatus = false;
- string msg = i.ToString();
- pubnub.publish(channel, msg, DisplayReturnMessage);
- while (!deliveryStatus) ;
- //long t = Timestamp();
- //inputs.Add(t, msg);
- Console.WriteLine("Message # " + i.ToString() + " published");
- }
-
- long midtime = Timestamp(pubnub);
- for (int i = total_msg / 2; i < total_msg; i++)
- {
- deliveryStatus = false;
- string msg = i.ToString();
- pubnub.publish(channel, msg, DisplayReturnMessage);
- while (!deliveryStatus) ;
- //long t = Timestamp();
- //inputs.Add(t, msg);
- Console.WriteLine("Message # " + i.ToString() + " published");
- }
-
-
- long endtime = Timestamp(pubnub);
-
- deliveryStatus = false;
-
- Console.WriteLine("DetailedHistory with start & end");
- pubnub.detailedHistory(channel, starttime, midtime, total_msg / 2, true, DisplayReturnMessage);
- while (!deliveryStatus) ;
-
- Console.WriteLine("DetailedHistory with start & reverse = true");
- string strResponse = "";
- if (objResponse.Equals(null))
- {
- Console.WriteLine("Null response");
- }
- else
- {
- IList<object> fields = objResponse as IList<object>;
- int j = 0;
- foreach (object item in fields)
- {
- strResponse = item.ToString();
- Console.WriteLine(String.Format("resp:{0} :: j: {1}", strResponse, j));
- if(j<total_msg/2)
- Console.WriteLine(j.ToString(), strResponse);
- j++;
- }
- }
-
- deliveryStatus = false;
- pubnub.detailedHistory(channel, midtime, -1, total_msg / 2, true, DisplayReturnMessage);
- while (!deliveryStatus) ;
-
- Console.WriteLine("DetailedHistory with start & reverse = false");
- strResponse = "";
- if (objResponse.Equals(null))
- {
- Console.WriteLine("Null response");
- }
- else
- {
- IList<object> fields = objResponse as IList<object>;
- int j = total_msg / 2;
- foreach (object item in fields)
- {
- strResponse = item.ToString();
- Console.WriteLine(String.Format("resp:{0} :: j: {1}", strResponse, j));
- if(j<total_msg)
- Console.WriteLine(j.ToString(), strResponse);
- j++;
- }
- }
-
-
- deliveryStatus = false;
- pubnub.detailedHistory(channel, midtime, -1, total_msg / 2, false, DisplayReturnMessage);
- while (!deliveryStatus) ;
- Console.WriteLine("\n******* DetailedHistory Messages Received ******* ");
- strResponse = "";
- if (objResponse.Equals(null))
- {
- Console.WriteLine("Null response");
- }
- else
- {
- IList<object> fields = objResponse as IList<object>;
- int j = 0;
- foreach (object item in fields)
- {
- strResponse = item.ToString();
- Console.WriteLine(String.Format("resp:{0} :: j: {1}", strResponse, j));
- if(j<total_msg/2)
- Console.WriteLine(j.ToString(), strResponse);
- j++;
- }
- }
- }
-
- public static void BasicEncryptionDecryptionTests ()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
-
- string enc = pc.encrypt("Pubnub Messaging API 1");
- Console.WriteLine ("Pubnub Messaging API 1 = " + enc);
- Console.WriteLine ("dec = " + pc.decrypt(enc));
-
- enc = pc.encrypt("yay!");
- Console.WriteLine ("yay = " + enc);
- Console.WriteLine ("dec = " + pc.decrypt(enc));
-
- Console.WriteLine ("Wi24KS4pcTzvyuGOHubiXg==: = " + pc.decrypt("Wi24KS4pcTzvyuGOHubiXg=="));
- Console.WriteLine ("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=: = " + pc.decrypt("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54="));
- Console.WriteLine ("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=: = " + pc.decrypt("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0="));
- Console.WriteLine ("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF = " + pc.decrypt("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF"));
- Console.WriteLine ("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g= = " + pc.decrypt("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g="));
-
- Console.WriteLine ("IDjZE9BHSjcX67RddfCYYg== = " + pc.decrypt("IDjZE9BHSjcX67RddfCYYg=="));
- Console.WriteLine ("Ns4TB41JjT2NCXaGLWSPAQ== = " + pc.decrypt("Ns4TB41JjT2NCXaGLWSPAQ=="));
-
- Console.WriteLine ("+BY5/miAA8aeuhVl4d13Kg== = " + pc.decrypt("+BY5/miAA8aeuhVl4d13Kg=="));
-
- Console.WriteLine ("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE= = " + pc.decrypt("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE="));
- Console.WriteLine ("q/xJqqN6qbiZMXYmiQC1Fw==: = " + pc.decrypt("q/xJqqN6qbiZMXYmiQC1Fw=="));
- }
-
-
- public static void Publish_Example()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "",
- false
- );
- string channel = "hello_world";
- string message = "Pubnub API Usage Example";
-
- deliveryStatus = false;
-
- pubnub.publish(channel, message, DisplayReturnMessage);
- //wait till the response is received from the server
- while (!deliveryStatus) ;
- IList<object> fields = objResponse as IList<object>;
- string strSent = fields[1].ToString();
- string strOne = fields[0].ToString();
- Console.WriteLine("Sent: " + strSent);
- Console.WriteLine("One: " + strOne);
- }
-
- public static void DetailedHistory_Example()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "",
- false);
- string channel = "testchannel";
- //pubnub.CIPHER_KEY = "";
- string msg = "Test Message";
- deliveryStatus = false;
- pubnub.publish(channel, msg, DisplayReturnMessage);
- while (!deliveryStatus) ;
-
- deliveryStatus = false;
- pubnub.detailedHistory(channel, 10, DisplayReturnMessage);
- while (!deliveryStatus) ;
- Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");
-
- if (objResponse.Equals(null))
- {
- Console.WriteLine("Null response");
- }
- else
- {
- IList<object> fields = objResponse as IList<object>;
-
- foreach (object item in fields)
- {
- string strResponse = item.ToString();
- Console.WriteLine(String.Format("resp:{0}", strResponse));
- Console.WriteLine(strResponse);
- }
- }
- }
-
- public static void DetailedHistory_Decrypted_Example()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "enigma",
- false);
- string channel = "testchannel";
- //pubnub.CIPHER_KEY = "enigma";
- string msg = "Test Message";
-
- deliveryStatus = false;
- pubnub.publish(channel, msg, DisplayReturnMessage);
- while (!deliveryStatus) ;
-
- deliveryStatus = false;
- pubnub.detailedHistory(channel, 1, DisplayReturnMessage);
- while (!deliveryStatus) ;
- Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");
-
- if (objResponse.Equals(null))
- {
- Console.WriteLine("Null response");
- }
- else
- {
- IList<object> fields = objResponse as IList<object>;
- Console.WriteLine("fields[0]: " + fields[0]);
- Console.WriteLine("fields[1]: " + fields[1]);
- //Assert.AreEqual(fields[0], msg);
- }
-
- }
-
- static void Timestamp_Example()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "",
- false
- );
-
- string strResponse = "";
- deliveryStatus = false;
-
- pubnub.time(DisplayReturnMessage);
- while (!deliveryStatus) ;
-
- IList<object> fields = objResponse as IList<object>;
- strResponse = fields[0].ToString();
- Console.WriteLine(strResponse);
- //Assert.AreNotEqual("0",strResponse);
- }
-
- public static void Subscribe_Example ()
- {
- Pubnub pubnub = new Pubnub (
- "demo",
- "demo",
- "",
- "",
- false);
- string channel = "hello_world";
-
- deliveryStatus = false;
-
- pubnub.subscribe (channel, DisplayReturnMessage);
-
- pubnub.publish (channel, "Test Message", DisplayReturnMessage);
-
- bool bStop = false;
- while (!bStop) {
- if (objResponse != null) {
- IList<object> fields = objResponse as IList<object>;
-
- if (fields [0] != null)
- {
- var myObjectArray = (from item in fields select item as object).ToArray ();
- IEnumerable enumerable = myObjectArray [0] as IEnumerable;
- if (enumerable != null) {
- foreach (object element in enumerable)
- {
- Console.WriteLine ("Resp:" + element.ToString ());
- bStop = true;
- }
- }
- }
- }
- }
- }
-
- public static void Presence_Example()
- {
- Pubnub pubnub = new Pubnub (
- "demo",
- "demo",
- "",
- "",
- false);
- string channel = "hello_world";
-
- deliveryStatus = false;
-
- pubnub.presence (channel, DisplayReturnMessage);
- Pubnub pubnub2 = new Pubnub (
- "demo",
- "demo",
- "",
- "",
- false);
-
- pubnub2.subscribe (channel, DisplayReturnMessage);
-
- bool bStop = false;
- while (!bStop) {
- if (objResponse != null) {
- IList<object> fields = objResponse as IList<object>;
-
- if (fields [0] != null)
- {
- var myObjectArray = (from item in fields select item as object).ToArray ();
- IEnumerable enumerable = myObjectArray [0] as IEnumerable;
- if (enumerable != null) {
- foreach (object element in enumerable)
- {
- Console.WriteLine ("Resp:" + element.ToString ());
- //bStop = true;
- }
- }
- }
- }
- }
-
- }
-
- public static void HereNow_Example()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "",
- false
- );
- string channel = "hello_world";
-
- deliveryStatus = false;
-
- pubnub.here_now(channel, DisplayReturnMessage);
- while (!deliveryStatus) ;
-
- string strResponse = "";
- if (objResponse.Equals (null)) {
- Console.WriteLine("Null response");
- }
- else
- {
- IList<object> fields =objResponse as IList<object>;
- foreach(object lst in fields)
- {
- strResponse = lst.ToString();
- Console.WriteLine(strResponse);
- }
- Dictionary<string, object> message = (Dictionary<string, object>)fields[0];
- foreach(KeyValuePair<String, object> entry in message)
- {
- Console.WriteLine("value:" + entry.Value + " " + "key:" + entry.Key);
- }
-
- object[] objUuid = (object[])message["uuids"];
- foreach (object obj in objUuid)
- {
- Console.WriteLine(obj.ToString());
- }
- }
- }
-
- static void MessageFeeder(List<object> feed)
- {
- foreach (object message in feed)
- {
- try
- {
- Dictionary<string, object> _messageHistory = (Dictionary<string, object>)(message);
- Console.WriteLine("Key: " + _messageHistory.ElementAt(0).Key + " - Value: " + _messageHistory.ElementAt(0).Value);
- }
- catch
- {
- Console.WriteLine(message.ToString());
- }
- }
- }
-
- static void MessageFeeder(object feed)
- {
- try
- {
- Dictionary<string, object> _message = (Dictionary<string, object>)(feed);
- for (int i = 0; i < _message.Count; i ++)
- Console.WriteLine("Key: " + _message.ElementAt(i).Key + " - Value: " + _message.ElementAt(i).Value);
- }
- catch
- {
- try
- {
- List<object> _message = (List<object>)feed;
- for (int i = 0; i < _message.Count; i++)
- Console.WriteLine(_message[i].ToString());
- }
- catch
- {
- Console.WriteLine("Time: " + feed.ToString());
- }
-
- }
- }
-
- static void DisplayReturnMessage(object result)
- {
- IList<object> message = result as IList<object>;
-
- if (message != null && message.Count >= 2)
- {
- for (int index = 0; index < message.Count; index++)
- {
- ParseObject(message[index], 1);
- }
- }
- else
- {
- Console.WriteLine("unable to parse data");
- }
- deliveryStatus = true;
- objResponse = result;
- }
-
- static void ParseObject(object result, int loop)
- {
- if (result is object[])
- {
- object[] arrResult = (object[])result;
- foreach (object item in arrResult)
- {
- if (!item.GetType().IsGenericType)
- {
- if (!item.GetType().IsArray)
- {
- Console.WriteLine(item.ToString());
- }
- else
- {
- ParseObject(item, loop + 1);
- }
- }
- else
- {
- ParseObject(item, loop + 1);
- }
- }
- }
- else if (result.GetType().IsGenericType && (result.GetType().Name == typeof(Dictionary<,>).Name))
- {
- Dictionary<string, object> itemList = (Dictionary<string, object>)result;
- foreach (KeyValuePair<string, object> pair in itemList)
- {
- Console.WriteLine(string.Format("key = {0}", pair.Key));
- if (pair.Value is object[])
- {
- Console.WriteLine("value = ");
- ParseObject(pair.Value, loop);
- }
- else
- {
- Console.WriteLine(string.Format("value = {0}", pair.Value));
- }
- }
- }
- else
- {
- Console.WriteLine(result.ToString());
- }
-
- }
- }
-}
-
View
114 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/Publish_Example.cs
@@ -1,114 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace PubNub_Messaging
-{
- internal static partial class Publish_Example
- {
- internal static void PublishDemo()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "",
- false);
-
- string channel = "my_channel";
-
- Console.WriteLine("Publish_Example");
-
- bool exitFlag = false;
- while (!exitFlag)
- {
- Console.WriteLine("Enter the message for publish. To exit loop, enter QUIT");
- string userinput = Console.ReadLine();
- if (userinput.ToLower() == "quit")
- {
- exitFlag = true;
- }
- else
- {
- pubnub.publish(channel, userinput, DisplayReturnMessage);
- }
- }
- }
-
- static void DisplayReturnMessage(object result)
- {
- IList<object> message = result as IList<object>;
-
- if (message != null && message.Count >= 2)
- {
- for (int index = 0; index < message.Count; index++)
- {
- ParseObject(message[index], 1);
- }
- }
- else
- {
- Console.WriteLine("unable to parse data");
- }
- }
-
- static void ParseObject(object result, int loop)
- {
- if (result is object[])
- {
- object[] arrResult = (object[])result;
- foreach (object item in arrResult)
- {
- if (!item.GetType().IsGenericType)
- {
- if (!item.GetType().IsArray)
- {
- Console.WriteLine(item.ToString());
- }
- else
- {
- ParseObject(item, loop + 1);
- }
- }
- else
- {
- ParseObject(item, loop + 1);
- }
- }
- }
- else if (result.GetType().IsGenericType && (result.GetType().Name == typeof(Dictionary<,>).Name))
- {
- Dictionary<string, object> itemList = (Dictionary<string, object>)result;
- foreach (KeyValuePair<string, object> pair in itemList)
- {
- Console.WriteLine(string.Format("key = {0}", pair.Key));
- if (pair.Value is object[])
- {
- Console.WriteLine("value = ");
- ParseObject(pair.Value, loop);
- }
- else
- {
- Console.WriteLine(string.Format("value = {0}", pair.Value));
- }
- }
- }
-
- }
-
- //static void DisplayPublishReturnMessage(object result)
- //{
- // List<object> message = result as List<object>;
-
- // if (message != null && message.Count >= 2)
- // {
- // Console.WriteLine(string.Format("[{0}, {1}, {2}]", message[0].ToString(),message[1].ToString(),message[2].ToString()));
- // }
- // else
- // {
- // Console.WriteLine("result is not List<object>");
- // }
- //}
- }
-}
View
2,925 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/PubnubBase.cs
0 additions, 2,925 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
21 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/PubnubExtend.cs
@@ -1,21 +0,0 @@
-#define TRACE
-
-using System;
-using PubNub_Messaging2;
-
-namespace PubNubConsole
-{
- public class PubnubExtend: PubnubBase
- {
- public PubnubExtend (string publish_key, string subscribe_key, string secret_key, string cipher_key, bool ssl_on): base (publish_key, subscribe_key, secret_key, cipher_key, ssl_on)
- {
- }
-
- public new void checkClientNetworkAvailability(Action<bool> callback)
- {
- }
-
- }
-
-}
-
View
226 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/Subscribe_Example.cs
@@ -1,226 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace PubNub_Messaging
-{
- internal static class Subscribe_Example
- {
- internal static void SubscribeDemo()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "",
- false);
-
- string channel = "my_channel";
-
- Console.WriteLine("Subscribe_Example");
-
- pubnub.subscribe(channel, DisplayReturnMessage);
-
- bool userexit = false;
- while (!userexit)
- {
- Console.WriteLine("For Unsubscribe");
- Console.WriteLine("Enter Y for UNSUBSCRIBE or ENTER X to EXIT subscribe loop");
- string userinput = Console.ReadLine();
- if (userinput.ToLower() == "y")
- {
- pubnub.unsubscribe(channel, DisplayReturnMessage);
- userexit = true;
- }
- else if (userinput.ToLower() == "x")
- {
- userexit = true;
- }
- }
- }
-
- internal static void SecureSubscribeDemo()
- {
- Pubnub pubnub = new Pubnub(
- "",
- "demo",
- "",
- "pandu",
- false);
-
- string channel = "my_channel";
-
- Console.WriteLine("Secure_Subscribe_Example");
-
- pubnub.subscribe(channel, DisplayReturnMessage);
-
- //Console.WriteLine("second channel");
- //pubnub.subscribe("second_channel", DisplaySubscribeReturnMessage1);
-
- //Console.WriteLine("third channel");
- //pubnub.subscribe("third_channel", DisplaySubscribeReturnMessage1);
-
- //Console.WriteLine("fourth channel");
- //pubnub.subscribe("fourth_channel", DisplaySubscribeReturnMessage1);
-
- //string channelNum = "";
- //do
- //{
- // Console.WriteLine("For Unsub");
- // Console.WriteLine("Enter 1 for my_channel, 2 for second_channel, 3 for third_channel, 4 for fourth channel, x for EXIT");
- // channelNum = Console.ReadLine();
- // if (channelNum == "1")
- // {
- // pubnub.unsubscribe(channel, DisplaySubscribeReturnMessage1);
- // }
- // else if (channelNum == "2")
- // {
- // pubnub.unsubscribe("second_channel", DisplaySubscribeReturnMessage1);
- // }
- // else if (channelNum == "3")
- // {
- // pubnub.unsubscribe("third_channel", DisplaySubscribeReturnMessage1);
- // }
- // else if (channelNum == "4")
- // {
- // pubnub.unsubscribe("fourth_channel", DisplaySubscribeReturnMessage1);
- // }
- //} while (channelNum.ToLower() != "x");
-
- //Console.WriteLine("Please wait...");
- //Console.ReadLine();
- }
-
- static void DisplayReturnMessage(object result)
- {
- IList<object> message = result as IList<object>;
-
- if (message != null && message.Count >= 2)
- {
- for (int index = 0; index < message.Count; index++)
- {
- ParseObject(message[index], 1);
- }
- }
- else
- {
- Console.WriteLine("unable to parse data");
- }
- }
-
- static void ParseObject(object result, int loop)
- {
- if (result is object[])
- {
- object[] arrResult = (object[])result;
- foreach (object item in arrResult)
- {
- if (!item.GetType().IsGenericType)
- {
- if (!item.GetType().IsArray)
- {
- Console.WriteLine(item.ToString());
- }
- else
- {
- ParseObject(item, loop + 1);
- }
- }
- else
- {
- ParseObject(item, loop + 1);
- }
- }
- }
- else if (result.GetType().IsGenericType && (result.GetType().Name == typeof(Dictionary<,>).Name))
- {
- Dictionary<string, object> itemList = (Dictionary<string, object>)result;
- foreach (KeyValuePair<string, object> pair in itemList)
- {
- Console.WriteLine(string.Format("key = {0}", pair.Key));
- if (pair.Value is object[])
- {
- Console.WriteLine("value = ");
- ParseObject(pair.Value, loop);
- }
- else
- {
- Console.WriteLine(string.Format("value = {0}", pair.Value));
- }
- }
- }
-
- }
-
-
- //static void DisplayReturnMessage(object result)
- //{
- // IList<object> message = result as IList<object>;
-
- // if (message != null && message.Count >= 2)
- // {
- // for (int index = 0; index < message.Count; index++)
- // {
- // if (!message[index].GetType().IsGenericType)
- // {
- // if (message[index] is object[])
- // {
- // object[] itemList = (object[])message[index];
- // for (int itemIndex = 0; itemIndex < itemList.Length; itemIndex++)
- // {
- // if (!itemList[itemIndex].GetType().IsGenericType)
- // {
- // if (itemList[itemIndex].GetType().IsPrimitive)
- // {
- // Console.WriteLine(string.Format("[{0}][{1}] = {2}", index, itemIndex, itemList[itemIndex].ToString()));
- // }
- // else
- // {
- // if (itemList[itemIndex] is object[])
- // {
- // object[] subitemList = (object[])itemList[itemIndex];
- // for (int subitemIndex = 0; subitemIndex < subitemList.Length; subitemIndex++)
- // {
- // Console.WriteLine(string.Format("[{0}][{1}][{2}] = {3}", index, itemIndex, subitemIndex, subitemList[subitemIndex].ToString()));
- // }
- // }
-
- // }
- // }
- // else if ((itemList[itemIndex].GetType().IsGenericType) && (itemList[itemIndex].GetType().Name == typeof(Dictionary<,>).Name))
- // {
- // Dictionary<string, object> subitemList = (Dictionary<string, object>)itemList[itemIndex];
- // foreach (KeyValuePair<string, object> pair in subitemList)
- // {
- // Console.WriteLine(string.Format("[{0}][{1}] = {2}", index, pair.Key, pair.Value));
- // }
- // }
- // }
- // }
- // else
- // {
- // Console.WriteLine(string.Format("[{0}] = {1}", index, message[index].ToString()));
- // }
- // }
- // else if ((message[index].GetType().IsGenericType) && (message[index].GetType().Name == typeof(Dictionary<,>).Name))
- // {
- // Dictionary<string, object> itemList = (Dictionary<string, object>)message[index];
- // foreach (KeyValuePair<string, object> pair in itemList)
- // {
- // Console.WriteLine(string.Format("[{0}][{1}] = {2}", index, pair.Key, pair.Value));
- // }
- // }
- // }
- // }
- // else
- // {
- // Console.WriteLine("result is not List<object>");
- // }
- //}
-
-
-
-
- }
-}
View
82 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/DetailedHistory_Example.cs
@@ -1,82 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace PubNub_Messaging
-{
- internal static class DetailedHistory_Example
- {
- /*public static void Main()
- {
- DetailedHistoryCountDemo();
- Console.ReadLine();
- }*/
-
- internal static void DetailedHistoryCountDemo()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "",
- false);
-
- string channel = "my_channel";
-
- //Console.WriteLine("Detailed History Count Demo");
- //pubnub.detailedHistory(channel, 100, DisplayDetailedHistory);
-
- //Console.WriteLine("Detailed History Count and reverse Demo");
- //pubnub.detailedHistory(channel, -1, -1, 100, true, DisplayDetailedHistory);
-
- //Console.WriteLine("Detailed History with start and end");
- //pubnub.detailedHistory(channel, 13499635513028988, 13499836911845528, 200, true, DisplayDetailedHistory);
-
- //Console.WriteLine("Detailed History with start");
- //pubnub.detailedHistory(channel, 13499635513028988, -1, 100, true, DisplayDetailedHistory);
-
- Console.WriteLine("Detailed History with end");
- pubnub.detailedHistory(channel, -1, 13499836911845528, 100, true, DisplayDetailedHistory);
- }
-
- static void DisplayDetailedHistory(object result)
- {
- try
- {
- IList<object> msg = result as IList<object>;
- if (msg != null && msg.Count > 0)
- {
- object[] history = msg[0] as object[];
- if (history != null && history.Length > 0)
- {
- Console.WriteLine(string.Format("Total history records = {0}", history.Length));
- foreach (object item in history)
- {
- if (!item.GetType().IsGenericType)
- {
- Console.WriteLine(item.ToString());
- }
- else if ((item.GetType().IsGenericType) && (item.GetType().Name == typeof(Dictionary<,>).Name))
- {
- Dictionary<string, object> itemList = (Dictionary<string, object>)item;
- foreach (KeyValuePair<string, object> pair in itemList)
- {
- Console.WriteLine(string.Format("Key = {0}; Value = {1}", pair.Key, pair.Value));
- }
- }
- else
- {
- Console.WriteLine(string.Format("Unhandled type {0}",item.ToString()));
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.ToString());
- }
- }
- }
-}
View
39 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/Here_Now_Example.cs
@@ -1,39 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace PubNub_Messaging
-{
- internal static class Here_Now_Example
- {
- /*public static void Main()
- {
- Here_Now_Demo();
- Console.ReadLine();
- }*/
-
- internal static void Here_Now_Demo()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "",
- false);
-
- string channel = "my/channel";
-
- Console.WriteLine("Here_Now_Example");
-
- pubnub.here_now<string>(channel, DisplayReturnMessage);
-
- }
-
- static void DisplayReturnMessage(string result )
- {
- Console.WriteLine(result);
- }
-
- }
-}
View
75 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/Main.cs
@@ -1,75 +0,0 @@
-using System;
-
-namespace PubNub_Messaging
-{
- class MainClass
- {
- public static void Main (string[] args)
- {
- //DetailedHistory_Example.DetailedHistoryCountDemo();
- //Here_Now_Example.Here_Now_Demo();
- //Presence_Example.PresenceDemo();
- //PresenceUnsubscribe_Example.PresenceUnsubscribeDemo();
- //Subscribe_Example.SecureSubscribeDemo();
- //Subscribe_Example.SubscribeDemo();
- //Publish_Example.PublishDemo();
-
- //Console.WriteLine ("Hello World!");
- Pubnub_Example.Main2();
- //Pubnub_Example2.TestEncryptedDetailedHistoryParams();
-
- //Subscribe Example
- //Pubnub_Example2.Subscribe_Example(); //success
-
- //Publish Example
- //Pubnub_Example2.Publish_Example(); //Success
-
- //Pubnub_Example2.BasicEncryptionDecryptionTests();//success
-
- //TestEncryptedDetailedHistoryParams
- //Pubnub_Example2.TestEncryptedDetailedHistoryParams (); //success
-
- //TestUnencryptedDetailedHistory
- //Pubnub_Example2.TestUnencryptedDetailedHistory(); //success
-
- //TestUnencryptedDetailedHistoryParams
- //Pubnub_Example2.TestUnencryptedDetailedHistoryParams(); //success
-
- //DetailedHistory_Example
- //Pubnub_Example2.DetailedHistory_Example(); //success
-
-
- //Timestamp
- //Pubnub_Example2.Timestamp(); //success
-
- //HereNow_Example
- //Pubnub_Example2.HereNow_Example(); //success
-
- //Presence_Example
- //Pubnub_Example2.Presence_Example(); //no response
-
- //TestUnencryptedHistory
- //Pubnub_Example2.TestUnencryptedHistory(); //success
-
-
- //TestUnencryptedDetailedHistory
- //Pubnub_Example2.TestUnencryptedDetailedHistory(); //success
-
- //TestEncryptedDetailedHistory
- //Pubnub_Example2.TestEncryptedDetailedHistory(); //success
-
- //TestUnencryptedDetailedHistoryParams
- //Pubnub_Example2.TestUnencryptedDetailedHistoryParams(); //success
-
- //TestEncryptedDetailedHistoryParams
- //Pubnub_Example2.TestEncryptedDetailedHistoryParams(); //success
-
- //TestEncryptedHistory
- //Pubnub_Example2.TestEncryptedHistory(); //Success
-
- //DetailedHistory_Decrypted_Example
- //Pubnub_Example2.DetailedHistory_Decrypted_Example(); //Success
-
- }
- }
-}
View
74 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/PresenceUnsubscribe_Example.cs
@@ -1,74 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace PubNub_Messaging
-{
- internal class PresenceUnsubscribe_Example
- {
- internal static void PresenceUnsubscribeDemo()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "",
- false);
-
- string channel = "my_channel";
-
- Console.WriteLine("PresenceUnsubscribe_Example");
-
- pubnub.presence_unsubscribe(channel, DisplayPresenceUnpresenceReturnMessage);
-
- }
-
- static void DisplayPresenceUnpresenceReturnMessage(object result)
- {
- IList<object> message = result as IList<object>;
-
- if (message != null && message.Count >= 2)
- {
- for(int index=0; index < message.Count; index++)
- {
- Console.WriteLine(string.Format("[{0}] = {1}",index, message[index].ToString()));
- object[] msg = message[0] as object[];
- if (msg != null)
- {
- foreach (object item in msg)
- {
- if (item is Dictionary<string, object>)
- {
- Dictionary<string, object> itemList = (Dictionary<string, object>)item;
- foreach (KeyValuePair<string, object> pair in itemList)
- {
- Console.WriteLine(string.Format("Key = {0}; Value = {1}", pair.Key, pair.Value));
- }
- }
- else if (item is object[])
- {
- object[] itemList = (object[])item;
- foreach (string innerItem in itemList)
- {
- Console.WriteLine(innerItem.ToString());
- }
- }
- else
- {
- Console.WriteLine(item.ToString());
- }
- }
- }
- }
- Console.WriteLine(string.Format("Channel = {0}", message[2].ToString()));
-
- }
- else
- {
- Console.WriteLine("result is not List<object>");
- }
- }
-
- }
-}
View
157 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/Presence_Example.cs
@@ -1,157 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace PubNub_Messaging
-{
- internal static class Presence_Example
- {
- internal static void PresenceDemo()
- {
- Pubnub pubnub = new Pubnub(
- "demo",
- "demo",
- "",
- "",
- false);
-
- string channel = "my_channel";
-
- Console.WriteLine("Presence_Example");
-
- pubnub.presence(channel, DisplayReturnMessage);
-
- bool pre_unsub = false;
- while (!pre_unsub)
- {
- Console.WriteLine("Enter y for Presence-Unsub; x to EXIT presence loop");
- string userchoice = Console.ReadLine();
- if (userchoice.ToLower() == "y")
- {
- Console.WriteLine("PresenceUnsubscribe_Example");
- pubnub.presence_unsubscribe(channel, DisplayReturnMessage);
-
- pre_unsub = true;
- }
- else if (userchoice.ToLower() == "x")
- {
- pre_unsub = true;
- }
- }
-
-
- }
-
- static void DisplayReturnMessage(object result)
- {
- IList<object> message = result as IList<object>;
-
- if (message != null && message.Count >= 2)
- {
- for (int index = 0; index < message.Count; index++)
- {
- ParseObject(message[index], 1);
- }
- }
- else
- {
- Console.WriteLine("unable to parse data");
- }
- }
-
- static void ParseObject(object result, int loop)
- {
- if (result is object[])
- {
- object[] arrResult = (object[])result;
- foreach (object item in arrResult)
- {
- if (!item.GetType().IsGenericType)
- {
- if (!item.GetType().IsArray)
- {
- Console.WriteLine(item.ToString());
- }
- else
- {
- ParseObject(item, loop + 1);
- }
- }
- else
- {
- ParseObject(item, loop + 1);
- }
- }
- }
- else if (result.GetType().IsGenericType && (result.GetType().Name == typeof(Dictionary<,>).Name))
- {
- Dictionary<string, object> itemList = (Dictionary<string, object>)result;
- foreach (KeyValuePair<string, object> pair in itemList)
- {
- Console.WriteLine(string.Format("key = {0}", pair.Key));
- if (pair.Value is object[])
- {
- Console.WriteLine("value = ");
- ParseObject(pair.Value, loop);
- }
- else
- {
- Console.WriteLine(string.Format("value = {0}", pair.Value));
- }
- }
- }
-
- }
-
- //static void DisplayReturnMessage(object result)
- //{
- // IList<object> message = result as IList<object>;
-
- // if (message != null && message.Count >= 2)
- // {
- // for (int index = 0; index < message.Count; index++)
- // {
- // if (!message[index].GetType().IsGenericType)
- // {
- // if (message[index] is object[])
- // {
- // object[] itemList = (object[])message[index];
- // for (int itemIndex = 0; itemIndex < itemList.Length; itemIndex++)
- // {
- // if (!itemList[itemIndex].GetType().IsGenericType)
- // {
- // Console.WriteLine(string.Format("[{0}][{1}] = {2}", index, itemIndex, itemList[itemIndex].ToString()));
- // }
- // else if ((itemList[itemIndex].GetType().IsGenericType) && (itemList[itemIndex].GetType().Name == typeof(Dictionary<,>).Name))
- // {
- // Dictionary<string, object> subitemList = (Dictionary<string, object>)itemList[itemIndex];
- // foreach (KeyValuePair<string, object> pair in subitemList)
- // {
- // Console.WriteLine(string.Format("[{0}][{1}] = {2}", index, pair.Key, pair.Value));
- // }
- // }
- // }
- // }
- // else
- // {
- // Console.WriteLine(string.Format("[{0}] = {1}", index, message[index].ToString()));
- // }
- // }
- // else if ((message[index].GetType().IsGenericType) && (message[index].GetType().Name == typeof(Dictionary<,>).Name))
- // {
- // Dictionary<string, object> itemList = (Dictionary<string, object>)message[index];
- // foreach (KeyValuePair<string, object> pair in itemList)
- // {
- // Console.WriteLine(string.Format("[{0}][{1}] = {2}",index, pair.Key, pair.Value));
- // }
- // }
- // }
- // }
- // else
- // {
- // Console.WriteLine("result is not List<object>");
- // }
- //}
- }
-}
View
65 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/PubNub-Console.csproj
@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
- <ProductVersion>10.0.0</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{9A973E1B-A9F2-400F-A5DE-C95C085A50EC}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <RootNamespace>PubNubConsole</RootNamespace>
- <AssemblyName>PubNub-Console</AssemblyName>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug</OutputPath>
- <DefineConstants>DEBUG;</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <PlatformTarget>x86</PlatformTarget>
- <Externalconsole>true</Externalconsole>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
- <DebugType>none</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <PlatformTarget>x86</PlatformTarget>
- <Externalconsole>true</Externalconsole>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- <Reference Include="System.Drawing" />
- <Reference Include="System.Runtime.Serialization" />
- <Reference Include="System.ServiceModel.Web" />
- <Reference Include="System.Web.Extensions" />
- <Reference Include="System.Xml" />
- <Reference Include="System.Xml.Linq" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Main.cs" />
- <Compile Include="AssemblyInfo.cs" />
- <Compile Include="PubNub-Example.cs" />
- <Compile Include="PubNub-Example2.cs" />
- <Compile Include="DetailedHistory_Example.cs" />
- <Compile Include="Here_Now_Example.cs" />
- <Compile Include="Presence_Example.cs" />
- <Compile Include="PresenceUnsubscribe_Example.cs" />
- <Compile Include="Subscribe_Example.cs" />
- <Compile Include="Publish_Example.cs" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <ItemGroup>
- <ProjectReference Include="..\PubNubLib\PubNubLib.csproj">
- <Project>{9C21E9C5-6F22-4A30-B4BA-E7A94E26710E}</Project>
- <Name>PubNubLib</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <None Include="app.config" />
- </ItemGroup>
-</Project>
View
213 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/PubNub-Example.cs
@@ -1,213 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.ComponentModel;
-using System.Threading;
-
-namespace PubNub_Messaging
-{
- public class Pubnub_Example
- {
- static public Pubnub pubnub;
-
- static public bool deliveryStatus = false;
- static public string channel = "";
-
- 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");
- 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 0 FOR EXIT OR QUIT");
-
- bool exitFlag = false;
-
- Console.WriteLine("");
- while (!exitFlag)
- {
- string userinput = Console.ReadLine();
- switch (userinput)
- {
- case "0":
- exitFlag = true;
- break;
- case "1":
- Console.WriteLine("Running subscribe()");
- pubnub.subscribe<string>(channel, DisplayReturnMessage);
- //System.Threading.Tasks.Task subtask = System.Threading.Tasks.Task.Factory.StartNew(() => pubnub.subscribe<string>(channel, DisplayReturnMessage));
- //pubnub.subscribe<object>(channel, DisplayReturnMessage);
- //pubnub.subscribe(channel, DisplayReturnMessage);
- break;
- case "2":
- Console.WriteLine("Running publish()");
- Console.WriteLine("Enter the message for publish. To exit loop, enter QUIT");
- string publishMsg = Console.ReadLine();
- pubnub.publish<string>(channel, publishMsg, DisplayReturnMessage);
- break;
- case "3":
- Console.WriteLine("Running presence()");
- pubnub.presence<string>(channel, DisplayReturnMessage);
- //System.Threading.Tasks.Task pretask = System.Threading.Tasks.Task.Factory.StartNew(() => pubnub.presence<string>(channel, DisplayReturnMessage));
- //pubnub.presence<object>(channel, DisplayReturnMessage);
- break;
- case "4":
- Console.WriteLine("Running detailed history()");
- pubnub.detailedHistory<string>(channel, 100, DisplayReturnMessage);
- //pubnub.detailedHistory<object>(channel, 100, DisplayReturnMessage);
- break;
- case "5":
- Console.WriteLine("Running Here_Now()");
- pubnub.here_now<string>(channel, DisplayReturnMessage);
- //pubnub.here_now<object>(channel, DisplayReturnMessage);
- break;
- case "6":
- Console.WriteLine("Running unsubscribe()");
- pubnub.unsubscribe<string>(channel, DisplayReturnMessage);
- //pubnub.unsubscribe<object>(channel, DisplayReturnMessage);
- break;
- case "7":
- Console.WriteLine("Running presence-unsubscribe()");
- pubnub.presence_unsubscribe<string>(channel, DisplayReturnMessage);
- break;
- case "8":
- Console.WriteLine("Running time()");
- pubnub.time<string>(DisplayReturnMessage);
- break;
- default:
- Console.WriteLine("INVALID CHOICE.");
- break;
- }
- }
-
- Console.WriteLine("\nPress any key to confirm exit.\n\n");
- Console.ReadLine();
-
- }
-
- static void DisplayReturnMessage(string result)
- {
- Console.WriteLine(result);
- }
-
- static void DisplayReturnMessage(object result)
- {
- IList<object> message = result as IList<object>;
-
- if (message != null && message.Count >= 1)
- {
- for (int index = 0; index < message.Count; index++)
- {
- ParseObject(message[index], 1);
- }
- }
- else
- {
- Console.WriteLine("unable to parse data");
- }
- }
-
- static void ParseObject(object result, int loop)
- {
- if (result is object[])
- {
- object[] arrResult = (object[])result;
- foreach (object item in arrResult)
- {
- if (item != null)
- {
- if (!item.GetType().IsGenericType)
- {
- if (!item.GetType().IsArray)
- {
- Console.WriteLine(item.ToString());
- }
- else
- {
- ParseObject(item, loop + 1);
- }
- }
- else
- {
- ParseObject(item, loop + 1);
- }
- }