PageRenderTime 198ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/PresenceUnsubscribe_Example.cs

https://github.com/jhey/pubnub-api
C# | 74 lines | 65 code | 9 blank | 0 comment | 9 complexity | b96b50f9695bd044892ec015de61ad1c MD5 | raw file
Possible License(s): Apache-2.0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace PubNub_Messaging
  6. {
  7. internal class PresenceUnsubscribe_Example
  8. {
  9. internal static void PresenceUnsubscribeDemo()
  10. {
  11. Pubnub pubnub = new Pubnub(
  12. "demo",
  13. "demo",
  14. "",
  15. "",
  16. false);
  17. string channel = "my_channel";
  18. Console.WriteLine("PresenceUnsubscribe_Example");
  19. pubnub.presence_unsubscribe(channel, DisplayPresenceUnpresenceReturnMessage);
  20. }
  21. static void DisplayPresenceUnpresenceReturnMessage(object result)
  22. {
  23. IList<object> message = result as IList<object>;
  24. if (message != null && message.Count >= 2)
  25. {
  26. for(int index=0; index < message.Count; index++)
  27. {
  28. Console.WriteLine(string.Format("[{0}] = {1}",index, message[index].ToString()));
  29. object[] msg = message[0] as object[];
  30. if (msg != null)
  31. {
  32. foreach (object item in msg)
  33. {
  34. if (item is Dictionary<string, object>)
  35. {
  36. Dictionary<string, object> itemList = (Dictionary<string, object>)item;
  37. foreach (KeyValuePair<string, object> pair in itemList)
  38. {
  39. Console.WriteLine(string.Format("Key = {0}; Value = {1}", pair.Key, pair.Value));
  40. }
  41. }
  42. else if (item is object[])
  43. {
  44. object[] itemList = (object[])item;
  45. foreach (string innerItem in itemList)
  46. {
  47. Console.WriteLine(innerItem.ToString());
  48. }
  49. }
  50. else
  51. {
  52. Console.WriteLine(item.ToString());
  53. }
  54. }
  55. }
  56. }
  57. Console.WriteLine(string.Format("Channel = {0}", message[2].ToString()));
  58. }
  59. else
  60. {
  61. Console.WriteLine("result is not List<object>");
  62. }
  63. }
  64. }
  65. }