Skip to content
Browse files

Merge branch 'CL-8955' of https://github.com/pubnub/pubnub-api into C…

…L-8955
  • Loading branch information...
2 parents dee9f16 + ee8c43b commit fc92d8b865d7aae2f0d5625b0638c5912ffbc345 @budgetpreneur budgetpreneur committed Mar 20, 2013
Showing with 2,568 additions and 1,443 deletions.
  1. 0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/Andr.Unit.csproj
  2. 0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/Common.cs
  3. 0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/EncryptionTests.cs
  4. 0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/Properties/AndroidManifest.xml
  5. 0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/PubnubUnitTest.cs
  6. +51 −20 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/Resources/Resource.designer.cs
  7. 0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenAClientIsPresented.cs
  8. 0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenAMessageIsPublished.cs
  9. 0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenDetailedHistoryIsRequested.cs
  10. 0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenGetRequestServerTime.cs
  11. 0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenSubscribedToAChannel.cs
  12. 0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenUnsubscribedToAChannel.cs
  13. 0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Android.NUnitLite/Android.NUnitLite.csproj
  14. 0 mono-for-android/3.4/Pubnub-Messaging/MonoDroid.Dialog/MonoDroid.Dialog.csproj
  15. 0 mono-for-android/3.4/Pubnub-Messaging/Newtonsoft.Json/Newtonsoft.Json.MonoDroid.csproj
  16. 0 mono-for-android/3.4/Pubnub-Messaging/Newtonsoft.Json/Newtonsoft.Json.MonoTouch.csproj
  17. 0 mono-for-android/3.4/Pubnub-Messaging/Newtonsoft.Json/Newtonsoft.Json.MonoTouch.pidb
  18. 0 mono-for-android/3.4/Pubnub-Messaging/Newtonsoft.Json/Utilities/LinqBridge.cs
  19. 0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Assets/AboutAssets.txt
  20. 0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/LaunchScreen.cs
  21. 0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/MainActivity.cs
  22. 0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Properties/AndroidManifest.xml
  23. 0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Properties/AssemblyInfo.cs
  24. 0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/PubNubMessaging.csproj
  25. +259 −73 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Pubnub.cs
  26. 0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/AboutResources.txt
  27. +82 −51 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/Resource.designer.cs
  28. 0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/drawable/Icon.png
  29. 0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/layout-large/Launch.axml
  30. 0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/layout-large/Main.axml
  31. 0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/layout/Launch.axml
  32. 0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/layout/Main.axml
  33. 0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/layout/Proxy.axml
  34. 0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/values/Strings.xml
  35. 0 mono-for-android/3.4/Pubnub-Messaging/Pubnub-Messaging.sln
  36. +8 −10 mono-for-android/3.4/Pubnub-Messaging/Pubnub-Messaging.userprefs
  37. +1 −1 mono-for-linux/3.4/Pubnub-Messaging/PubNub-Console/AssemblyInfo.cs
  38. 0 mono-for-linux/3.4/Pubnub-Messaging/PubNub-Console/PubNub-Messaging.cs
  39. +7 −6 mono-for-linux/3.4/Pubnub-Messaging/PubNub-Console/PubNub-Messaging.csproj
  40. BIN mono-for-linux/3.4/Pubnub-Messaging/PubNub-Console/PubNub-Messaging.pidb
  41. +259 −73 mono-for-linux/3.4/Pubnub-Messaging/PubNub-Console/Pubnub.cs
  42. +426 −273 mono-for-linux/3.4/Pubnub-Messaging/PubNub-Console/PubnubExample.cs
  43. 0 mono-for-linux/3.4/Pubnub-Messaging/PubNub-Console/app.config
  44. 0 mono-for-linux/3.4/Pubnub-Messaging/PubNub-Messaging.sln
  45. +38 −30 mono-for-linux/3.4/Pubnub-Messaging/PubNub-Messaging.userprefs
  46. +1 −1 mono-for-linux/3.4/Pubnub-Messaging/PubNubTest/AssemblyInfo.cs
  47. +1 −1 mono-for-linux/3.4/Pubnub-Messaging/PubNubTest/Common.cs
  48. +453 −454 mono-for-linux/3.4/Pubnub-Messaging/PubNubTest/EncryptionTests.cs
  49. +12 −12 mono-for-linux/3.4/Pubnub-Messaging/PubNubTest/PubNub-Messaging.Tests.csproj
  50. BIN mono-for-linux/3.4/Pubnub-Messaging/PubNubTest/PubNub-Messaging.Tests.pidb
  51. +1 −1 mono-for-linux/3.4/Pubnub-Messaging/PubNubTest/PubnubUnitTest.cs
  52. +1 −1 mono-for-linux/3.4/Pubnub-Messaging/PubNubTest/WhenAClientIsPresented.cs
  53. +5 −1 mono-for-linux/3.4/Pubnub-Messaging/PubNubTest/WhenAMessageIsPublished.cs
  54. 0 mono-for-linux/3.4/Pubnub-Messaging/PubNubTest/WhenDetailedHistoryIsRequested.cs
  55. 0 mono-for-linux/3.4/Pubnub-Messaging/PubNubTest/WhenGetRequestHistoryMessages.cs
  56. +0 −1 mono-for-linux/3.4/Pubnub-Messaging/PubNubTest/WhenGetRequestServerTime.cs
  57. 0 mono-for-linux/3.4/Pubnub-Messaging/PubNubTest/WhenSubscribedToAChannel.cs
  58. 0 mono-for-linux/3.4/Pubnub-Messaging/PubNubTest/WhenUnsubscribedToAChannel.cs
  59. +2 −3 mono-for-linux/3.4/Pubnub-Messaging/PubNubTest/app.config
  60. 0 mono-for-mac/3.4/PubNub-Messaging/PubNub-Console/AssemblyInfo.cs
  61. 0 mono-for-mac/3.4/PubNub-Messaging/PubNub-Console/PubNub-Messaging.cs
  62. 0 mono-for-mac/3.4/PubNub-Messaging/PubNub-Console/PubNub-Messaging.csproj
  63. +259 −73 mono-for-mac/3.4/PubNub-Messaging/PubNub-Console/Pubnub.cs
  64. +426 −273 mono-for-mac/3.4/PubNub-Messaging/PubNub-Console/PubnubExample.cs
  65. 0 mono-for-mac/3.4/PubNub-Messaging/PubNub-Console/app.config
  66. 0 mono-for-mac/3.4/PubNub-Messaging/PubNub-Messaging.sln
  67. +11 −8 mono-for-mac/3.4/PubNub-Messaging/PubNub-Messaging.userprefs
  68. 0 mono-for-mac/3.4/PubNub-Messaging/PubNubTest/AssemblyInfo.cs
  69. 0 mono-for-mac/3.4/PubNub-Messaging/PubNubTest/Common.cs
  70. 0 mono-for-mac/3.4/PubNub-Messaging/PubNubTest/EncryptionTests.cs
  71. 0 mono-for-mac/3.4/PubNub-Messaging/PubNubTest/PubNub-Messaging.Tests.csproj
  72. 0 mono-for-mac/3.4/PubNub-Messaging/PubNubTest/PubnubUnitTest.cs
  73. +1 −1 mono-for-mac/3.4/PubNub-Messaging/PubNubTest/WhenAClientIsPresented.cs
  74. 0 mono-for-mac/3.4/PubNub-Messaging/PubNubTest/WhenAMessageIsPublished.cs
  75. 0 mono-for-mac/3.4/PubNub-Messaging/PubNubTest/WhenDetailedHistoryIsRequested.cs
  76. 0 mono-for-mac/3.4/PubNub-Messaging/PubNubTest/WhenGetRequestHistoryMessages.cs
  77. 0 mono-for-mac/3.4/PubNub-Messaging/PubNubTest/WhenGetRequestServerTime.cs
  78. 0 mono-for-mac/3.4/PubNub-Messaging/PubNubTest/WhenSubscribedToAChannel.cs
  79. 0 mono-for-mac/3.4/PubNub-Messaging/PubNubTest/WhenUnsubscribedToAChannel.cs
  80. 0 mono-for-mac/3.4/PubNub-Messaging/PubNubTest/app.config
  81. 0 monotouch/3.4/Pubnub-Messaging/Newtonsoft.Json/Newtonsoft.Json.MonoDroid.csproj
  82. 0 monotouch/3.4/Pubnub-Messaging/Newtonsoft.Json/Newtonsoft.Json.MonoTouch.csproj
  83. 0 monotouch/3.4/Pubnub-Messaging/Newtonsoft.Json/Newtonsoft.Json.MonoTouch.pidb
  84. 0 monotouch/3.4/Pubnub-Messaging/Newtonsoft.Json/Utilities/LinqBridge.cs
  85. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging.Tests/AppDelegate.cs
  86. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging.Tests/Common.cs
  87. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging.Tests/EncryptionTests.cs
  88. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging.Tests/Info.plist
  89. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging.Tests/Main.cs
  90. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging.Tests/Pubnub-Messaging.Tests.csproj
  91. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging.Tests/PubnubUnitTest.cs
  92. +1 −1 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging.Tests/WhenAClientIsPresented.cs
  93. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging.Tests/WhenAMessageIsPublished.cs
  94. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging.Tests/WhenDetailedHistoryIsRequested.cs
  95. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging.Tests/WhenGetRequestHistoryMessages.cs
  96. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging.Tests/WhenGetRequestServerTime.cs
  97. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging.Tests/WhenSubscribedToAChannel.cs
  98. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging.Tests/WhenUnsubscribedToAChannel.cs
  99. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging.sln
  100. +4 −2 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging.userprefs
  101. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging/AppDelegate.cs
  102. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging/DeviceHardware.cs
  103. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging/GraphHeader.cs
  104. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging/GraphHeaderView.cs
  105. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging/Info.plist
  106. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging/InputAlertView.cs
  107. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging/Main.cs
  108. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging/PerformanceHeader.cs
  109. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging/PerformanceHeaderView.cs
  110. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging/Pubnub-Messaging.csproj
  111. +259 −73 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging/Pubnub.cs
  112. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging/Pubnub_MessagingMain.cs
  113. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging/Pubnub_MessagingSpeedTest.cs
  114. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging/Pubnub_MessagingSub.cs
  115. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging/SdHeader.cs
  116. 0 monotouch/3.4/Pubnub-Messaging/Pubnub-Messaging/SdHeaderView.cs
View
0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/Andr.Unit.csproj 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/Common.cs 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/EncryptionTests.cs 100644 → 100755
File mode changed.
View
0 ...or-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/Properties/AndroidManifest.xml 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/PubnubUnitTest.cs 100644 → 100755
File mode changed.
View
71 ...or-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/Resources/Resource.designer.cs
@@ -1,3 +1,4 @@
+#pragma warning disable 1591
// ------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
@@ -8,13 +9,25 @@
// </autogenerated>
// ------------------------------------------------------------------------------
+[assembly: Android.Runtime.ResourceDesignerAttribute("Andr.Unit.Resource", IsApplication=true)]
+
namespace Andr.Unit
{
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
public partial class Resource
{
+ Resource()
+ {
+ global::Android.Runtime.ResourceIdManager.UpdateIdValues ();
+ }
+
+ public static void UpdateIdValues()
+ {
+ }
+
public partial class Attribute
{
@@ -29,6 +42,9 @@ public partial class Drawable
// aapt resource value: 0x7f020000
public const int Icon = 2130837504;
+ // aapt resource value: 0x7f020001
+ public const int monoandroidsplash = 2130837505;
+
private Drawable()
{
}
@@ -37,35 +53,35 @@ private Drawable()
public partial class Id
{
- // aapt resource value: 0x7f050002
- public const int dialog_BoolField = 2131034114;
+ // aapt resource value: 0x7f060002
+ public const int dialog_BoolField = 2131099650;
- // aapt resource value: 0x7f050003
- public const int dialog_Button = 2131034115;
+ // aapt resource value: 0x7f060003
+ public const int dialog_Button = 2131099651;
- // aapt resource value: 0x7f050000
- public const int dialog_LabelField = 2131034112;
+ // aapt resource value: 0x7f060000
+ public const int dialog_LabelField = 2131099648;
- // aapt resource value: 0x7f050001
- public const int dialog_LabelSubtextField = 2131034113;
+ // aapt resource value: 0x7f060001
+ public const int dialog_LabelSubtextField = 2131099649;
- // aapt resource value: 0x7f050005
- public const int dialog_Panel = 2131034117;
+ // aapt resource value: 0x7f060005
+ public const int dialog_Panel = 2131099653;
- // aapt resource value: 0x7f050006
- public const int dialog_RadioButtonList = 2131034118;
+ // aapt resource value: 0x7f060006
+ public const int dialog_RadioButtonList = 2131099654;
- // aapt resource value: 0x7f050007
- public const int dialog_Spinner = 2131034119;
+ // aapt resource value: 0x7f060007
+ public const int dialog_Spinner = 2131099655;
- // aapt resource value: 0x7f050004
- public const int dialog_ValueField = 2131034116;
+ // aapt resource value: 0x7f060004
+ public const int dialog_ValueField = 2131099652;
- // aapt resource value: 0x7f050008
- public const int iFormFieldValue = 2131034120;
+ // aapt resource value: 0x7f060008
+ public const int iFormFieldValue = 2131099656;
- // aapt resource value: 0x7f050009
- public const int myButton = 2131034121;
+ // aapt resource value: 0x7f060009
+ public const int myButton = 2131099657;
private Id()
{
@@ -129,6 +145,9 @@ public partial class Layout
// aapt resource value: 0x7f030011
public const int Main = 2130903057;
+ // aapt resource value: 0x7f030012
+ public const int monoandroidsplash = 2130903058;
+
private Layout()
{
}
@@ -147,5 +166,17 @@ private String()
{
}
}
+
+ public partial class Style
+ {
+
+ // aapt resource value: 0x7f050000
+ public const int Mono_Android_Theme_Splash = 2131034112;
+
+ private Style()
+ {
+ }
+ }
}
}
+#pragma warning restore 1591
View
0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenAClientIsPresented.cs 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenAMessageIsPublished.cs 100644 → 100755
File mode changed.
View
0 ...android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenDetailedHistoryIsRequested.cs 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenGetRequestServerTime.cs 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenSubscribedToAChannel.cs 100644 → 100755
File mode changed.
View
0 ...for-android/3.4/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenUnsubscribedToAChannel.cs 100644 → 100755
File mode changed.
View
0 ...-android/3.4/Pubnub-Messaging/Andr.Unit-master/Android.NUnitLite/Android.NUnitLite.csproj 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/MonoDroid.Dialog/MonoDroid.Dialog.csproj 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/Newtonsoft.Json/Newtonsoft.Json.MonoDroid.csproj 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/Newtonsoft.Json/Newtonsoft.Json.MonoTouch.csproj 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/Newtonsoft.Json/Newtonsoft.Json.MonoTouch.pidb 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/Newtonsoft.Json/Utilities/LinqBridge.cs 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Assets/AboutAssets.txt 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/LaunchScreen.cs 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/MainActivity.cs 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Properties/AndroidManifest.xml 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Properties/AssemblyInfo.cs 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/PubNubMessaging.csproj 100644 → 100755
File mode changed.
View
332 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Pubnub.cs 100644 → 100755
@@ -1,5 +1,4 @@
-//Build Date: March 07, 2013
-
+//Build Date: March 16, 2013
#if (__MonoCS__)
#define TRACE
#endif
@@ -38,17 +37,18 @@
using System.Security.Cryptography.X509Certificates;
#endif
+
namespace PubNubMessaging.Core
{
// INotifyPropertyChanged provides a standard event for objects to notify clients that one of its properties has changed
public class Pubnub : INotifyPropertyChanged
{
- const int pubnubWebRequestCallbackIntervalInSeconds = 310;
- const int pubnubOperationTimeoutIntervalInSeconds = 15;
- const int pubnubNetworkTcpCheckIntervalInSeconds = 15;
- const int pubnubNetworkCheckRetries = 50;
- const int pubnubWebRequestRetryIntervalInSeconds = 10;
- bool enableResumeOnReconnect = true;
+ int _pubnubWebRequestCallbackIntervalInSeconds = 310;
+ int _pubnubOperationTimeoutIntervalInSeconds = 15;
+ int _pubnubNetworkTcpCheckIntervalInSeconds = 15;
+ int _pubnubNetworkCheckRetries = 50;
+ int _pubnubWebRequestRetryIntervalInSeconds = 10;
+ bool _enableResumeOnReconnect = true;
bool overrideTcpKeepAlive = true;
const LoggingMethod.Level pubnubLogLevel = LoggingMethod.Level.Error;
@@ -76,6 +76,83 @@ public void RaisePropertyChanged(string propertyName)
ConcurrentDictionary<string, Timer> _channelReconnectTimer = new ConcurrentDictionary<string, Timer>();
ConcurrentDictionary<Uri, Timer> _channelHeartbeatTimer = new ConcurrentDictionary<Uri, Timer>();
+ internal int SubscribeTimeout
+ {
+ get
+ {
+ return _pubnubWebRequestCallbackIntervalInSeconds;
+ }
+
+ set
+ {
+ _pubnubWebRequestCallbackIntervalInSeconds = value;
+ }
+ }
+
+ internal int NonSubscribeTimeout
+ {
+ get
+ {
+ return _pubnubOperationTimeoutIntervalInSeconds;
+ }
+
+ set
+ {
+ _pubnubOperationTimeoutIntervalInSeconds = value;
+ }
+ }
+
+ internal int NetworkCheckMaxRetries
+ {
+ get
+ {
+ return _pubnubNetworkCheckRetries;
+ }
+
+ set
+ {
+ _pubnubNetworkCheckRetries = value;
+ }
+ }
+
+ internal int NetworkCheckRetryInterval
+ {
+ get
+ {
+ return _pubnubWebRequestRetryIntervalInSeconds;
+ }
+
+ set
+ {
+ _pubnubWebRequestRetryIntervalInSeconds = value;
+ }
+ }
+
+ internal int HeartbeatInterval
+ {
+ get
+ {
+ return _pubnubNetworkTcpCheckIntervalInSeconds;
+ }
+
+ set
+ {
+ _pubnubNetworkTcpCheckIntervalInSeconds = value;
+ }
+ }
+
+ internal bool EnableResumeOnReconnect
+ {
+ get
+ {
+ return _enableResumeOnReconnect;
+ }
+ set
+ {
+ _enableResumeOnReconnect = value;
+ }
+ }
+
private IPubnubUnitTest _pubnubUnitTest;
public IPubnubUnitTest PubnubUnitTest
{
@@ -197,7 +274,7 @@ private void Init(string publishKey, string subscribeKey, string secretKey, stri
private void ReconnectNetwork<T>(ReconnectState<T> netState)
{
- System.Threading.Timer timer = new Timer(new TimerCallback(ReconnectNetworkCallback<T>), netState, 0, pubnubNetworkTcpCheckIntervalInSeconds * 1000);
+ System.Threading.Timer timer = new Timer(new TimerCallback(ReconnectNetworkCallback<T>), netState, 0, _pubnubNetworkTcpCheckIntervalInSeconds * 1000);
_channelReconnectTimer.AddOrUpdate(string.Join(",",netState.Channels), timer, (key, oldState) => timer);
}
@@ -222,7 +299,7 @@ void ReconnectNetworkCallback<T>(Object reconnectState)
else
{
_channelInternetRetry.AddOrUpdate(channel, 1, (key, oldValue) => oldValue + 1);
- LoggingMethod.WriteToLog(string.Format("DateTime {0}, {1} {2} reconnectNetworkCallback. Retry {3} of {4}", DateTime.Now.ToString(), channel, netState.Type, _channelInternetRetry[channel], pubnubNetworkCheckRetries), LoggingMethod.LevelInfo);
+ LoggingMethod.WriteToLog(string.Format("DateTime {0}, {1} {2} reconnectNetworkCallback. Retry {3} of {4}", DateTime.Now.ToString(), channel, netState.Type, _channelInternetRetry[channel], _pubnubNetworkCheckRetries), LoggingMethod.LevelInfo);
}
}
@@ -245,7 +322,7 @@ void ReconnectNetworkCallback<T>(Object reconnectState)
break;
}
}
- else if (_channelInternetRetry[channel] >= pubnubNetworkCheckRetries)
+ else if (_channelInternetRetry[channel] >= _pubnubNetworkCheckRetries)
{
if (_channelReconnectTimer.ContainsKey(channel))
{
@@ -316,8 +393,8 @@ void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
if (overrideTcpKeepAlive)
{
heartBeatTimer.Change(
- (-1 == pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : pubnubNetworkTcpCheckIntervalInSeconds * 1000,
- (-1 == pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : pubnubNetworkTcpCheckIntervalInSeconds * 1000);
+ (-1 == _pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : _pubnubNetworkTcpCheckIntervalInSeconds * 1000,
+ (-1 == _pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : _pubnubNetworkTcpCheckIntervalInSeconds * 1000);
}
LoggingMethod.WriteToLog(string.Format("DateTime {0}, System entered into Resume/Awake Mode.", DateTime.Now.ToString()), LoggingMethod.LevelInfo);
@@ -1076,7 +1153,7 @@ private void MultiChannelSubscribeRequest<T>(ResponseType type, string[] channel
if (_channelInternetStatus.ContainsKey(multiChannel) && (!_channelInternetStatus[multiChannel]) && _pubnetSystemActive)
{
- if (_channelInternetRetry.ContainsKey(multiChannel) && (_channelInternetRetry[multiChannel] >= pubnubNetworkCheckRetries))
+ if (_channelInternetRetry.ContainsKey(multiChannel) && (_channelInternetRetry[multiChannel] >= _pubnubNetworkCheckRetries))
{
LoggingMethod.WriteToLog(string.Format("DateTime {0}, Subscribe channel={1} - No internet connection. MAXed retries for internet ", DateTime.Now.ToString(), multiChannel), LoggingMethod.LevelInfo);
MultiplexExceptionHandler<T>(type,channels, userCallback, connectCallback, true, false);
@@ -1121,7 +1198,6 @@ private void MultiChannelSubscribeRequest<T>(ResponseType type, string[] channel
lastTimetoken = lastSubscribeTimetoken;
}
}
-
LoggingMethod.WriteToLog(string.Format("DateTime {0}, Building request for channel(s)={1} with timetoken={2}", DateTime.Now.ToString(), string.Join(",",channels),lastTimetoken), LoggingMethod.LevelInfo);
// Build URL
Uri requestUrl = BuildMultiChannelSubscribeRequest(channels, (Convert.ToInt64(timetoken.ToString()) == 0) ? Convert.ToInt64(timetoken.ToString()) : lastTimetoken);
@@ -1362,13 +1438,13 @@ private bool UrlProcessRequest<T>(Uri requestUri, RequestState<T> pubnubRequestS
//Eventhough heart-beat is disabled, run one time to check internet connection by setting dueTime=0
heartBeatTimer = new System.Threading.Timer(
new TimerCallback(OnPubnubHeartBeatTimeoutCallback<T>), pubnubRequestState, 0,
- (-1 == pubnubNetworkTcpCheckIntervalInSeconds) ? Timeout.Infinite : pubnubNetworkTcpCheckIntervalInSeconds * 1000);
+ (-1 == _pubnubNetworkTcpCheckIntervalInSeconds) ? Timeout.Infinite : _pubnubNetworkTcpCheckIntervalInSeconds * 1000);
_channelHeartbeatTimer.AddOrUpdate(requestUri, heartBeatTimer, (key, oldState) => heartBeatTimer);
}
else
{
#if ((!__MonoCS__) && (!SILVERLIGHT) && !WINDOWS_PHONE)
- request.ServicePoint.SetTcpKeepAlive(true, pubnubNetworkTcpCheckIntervalInSeconds * 1000, 1000);
+ request.ServicePoint.SetTcpKeepAlive(true, _pubnubNetworkTcpCheckIntervalInSeconds * 1000, 1000);
#endif
}
LoggingMethod.WriteToLog(string.Format("DateTime {0}, Request={1}", DateTime.Now.ToString(), requestUri.ToString()), LoggingMethod.LevelInfo);
@@ -1570,7 +1646,8 @@ void ConnectToHostAndSendRequest<T>(bool sslEnabled, TcpClient tcpClient, Reques
throw new Exception("SSL error");
}
}
-#endif
+#endif
+
private void ConnectToHostAndSendRequestCallback<T>(IAsyncResult asynchronousResult)
{
StateObject<T> asynchStateObject = asynchronousResult.AsyncState as StateObject<T>;
@@ -1694,7 +1771,6 @@ private void SendRequestUsingTcpClient<T>(Uri requestUri, RequestState<T> pubnub
{
TcpClient tcpClient = new TcpClient();
tcpClient.NoDelay = false;
-
#if(!MONODROID)
tcpClient.SendTimeout = pubnubRequestState.Request.Timeout;
#endif
@@ -1870,11 +1946,11 @@ void ProcessResponseCallbackWebExceptionHandler<T>(WebException webEx, RequestSt
else
{
_channelInternetRetry.AddOrUpdate(channel, 1, (key, oldValue) => oldValue + 1);
- LoggingMethod.WriteToLog(string.Format("DateTime {0} {1} channel = {2} _urlRequest - Internet connection retry {3} of {4}", DateTime.Now.ToString(), asynchRequestState.Type, string.Join(",", asynchRequestState.Channels), _channelInternetRetry[channel], pubnubNetworkCheckRetries), LoggingMethod.LevelInfo);
+ LoggingMethod.WriteToLog(string.Format("DateTime {0} {1} channel = {2} _urlRequest - Internet connection retry {3} of {4}", DateTime.Now.ToString(), asynchRequestState.Type, string.Join(",", asynchRequestState.Channels), _channelInternetRetry[channel], _pubnubNetworkCheckRetries), LoggingMethod.LevelInfo);
}
_channelInternetStatus[channel] = false;
- Thread.Sleep(pubnubWebRequestRetryIntervalInSeconds * 1000);
+ Thread.Sleep(_pubnubWebRequestRetryIntervalInSeconds * 1000);
}
}
#endif
@@ -1984,11 +2060,11 @@ private int GetTimeoutInSecondsForResponseType(ResponseType type)
int timeout;
if (type == ResponseType.Subscribe || type == ResponseType.Presence)
{
- timeout = pubnubWebRequestCallbackIntervalInSeconds;
+ timeout = _pubnubWebRequestCallbackIntervalInSeconds;
}
else
{
- timeout = pubnubOperationTimeoutIntervalInSeconds;
+ timeout = _pubnubOperationTimeoutIntervalInSeconds;
}
return timeout;
}
@@ -2010,8 +2086,8 @@ private void TerminateHeartbeatTimer(Uri requestUri)
try
{
requestHeatbeatTimer.Change(
- (-1 == pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : pubnubNetworkTcpCheckIntervalInSeconds * 1000,
- (-1 == pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : pubnubNetworkTcpCheckIntervalInSeconds * 1000);
+ (-1 == _pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : _pubnubNetworkTcpCheckIntervalInSeconds * 1000,
+ (-1 == _pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : _pubnubNetworkTcpCheckIntervalInSeconds * 1000);
requestHeatbeatTimer.Dispose();
}
catch (ObjectDisposedException ex)
@@ -2066,8 +2142,8 @@ private void TerminateReconnectTimer(string channelName)
{
Timer channelReconnectTimer = _channelReconnectTimer[channelName];
channelReconnectTimer.Change(
- (-1 == pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : pubnubNetworkTcpCheckIntervalInSeconds * 1000,
- (-1 == pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : pubnubNetworkTcpCheckIntervalInSeconds * 1000);
+ (-1 == _pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : _pubnubNetworkTcpCheckIntervalInSeconds * 1000,
+ (-1 == _pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : _pubnubNetworkTcpCheckIntervalInSeconds * 1000);
channelReconnectTimer.Dispose();
Timer removedTimer = null;
bool removed = _channelReconnectTimer.TryRemove(channelName, out removedTimer);
@@ -2109,22 +2185,28 @@ private void ResponseToConnectCallback<T>(List<object> result, ResponseType type
select channel.Key;
foreach (string channel in newChannels)
{
- if (!IsPresenceChannel(channel))
+ string jsonString = "";
+ List<object> connectResult = new List<object>();
+ //if (!IsPresenceChannel(channel))
+ //{
+ switch (type)
{
- switch (type)
- {
- case ResponseType.Subscribe:
- string jsonString = "";
- List<object> connectResult = new List<object>();
- jsonString = string.Format("[1, \"Connected\"]");
- connectResult = (List<object>)JsonConvert.DeserializeObject<List<object>>(jsonString);
- connectResult.Add(channel);
- GoToCallback<T>(connectResult, connectCallback);
- break;
- default:
- break;
- }
+ case ResponseType.Subscribe:
+ jsonString = string.Format("[1, \"Connected\"]");
+ connectResult = (List<object>)JsonConvert.DeserializeObject<List<object>>(jsonString);
+ connectResult.Add(channel);
+ GoToCallback<T>(connectResult, connectCallback);
+ break;
+ case ResponseType.Presence:
+ jsonString = string.Format("[1, \"Presence Connected\"]");
+ connectResult = (List<object>)JsonConvert.DeserializeObject<List<object>>(jsonString);
+ connectResult.Add(channel.Replace("-pnpres", ""));
+ GoToCallback<T>(connectResult, connectCallback);
+ break;
+ default:
+ break;
}
+ //}
}
}
@@ -2452,18 +2534,38 @@ private void MultiplexExceptionHandler<T>(ResponseType type, string[] channels,
string[] activeChannels = _multiChannelSubscribe.Keys.ToArray<string>();
MultiChannelUnSubscribeInit<T>(ResponseType.Unsubscribe, string.Join(",", activeChannels), null, null, null);
- List<object> errorResult = new List<object>();
- string jsonString = string.Format("[0, \"Unsubscribed after {0} failed retries\"]", pubnubNetworkCheckRetries);
- errorResult = (List<object>)JsonConvert.DeserializeObject<List<object>>(jsonString);
- string activeMultiChannel = string.Join(",", activeChannels).Replace("-pnpres", "");
- errorResult.Add(activeMultiChannel.Split(','));
-
- LoggingMethod.WriteToLog(string.Format("DateTime {0}, Subscribe JSON network error response={1}", DateTime.Now.ToString(), jsonString), LoggingMethod.LevelInfo);
+ string[] subscribeChannels = activeChannels.Where(filterChannel => !filterChannel.Contains("-pnpres")).ToArray();
+ string[] presenceChannels = activeChannels.Where(filterChannel => filterChannel.Contains("-pnpres")).ToArray();
- if (userCallback != null)
+ if (subscribeChannels != null && subscribeChannels.Length > 0)
{
- GoToCallback<T>(errorResult, userCallback);
+ List<object> errorResult = new List<object>();
+ string jsonString = string.Format("[0, \"Unsubscribed after {0} failed retries\"]", _pubnubNetworkCheckRetries);
+ errorResult = (List<object>)JsonConvert.DeserializeObject<List<object>>(jsonString);
+ string activeMultiChannel = string.Join(",", subscribeChannels);
+ errorResult.Add(activeMultiChannel.Split(','));
+
+ if (userCallback != null)
+ {
+ GoToCallback<T>(errorResult, userCallback);
+ }
+ LoggingMethod.WriteToLog(string.Format("DateTime {0}, Subscribe JSON network error response={1}", DateTime.Now.ToString(), jsonString), LoggingMethod.LevelInfo);
}
+ if (presenceChannels != null && presenceChannels.Length > 0)
+ {
+ List<object> errorResult = new List<object>();
+ string jsonString = string.Format("[0, \"Presence Unsubscribed after {0} failed retries\"]", _pubnubNetworkCheckRetries);
+ errorResult = (List<object>)JsonConvert.DeserializeObject<List<object>>(jsonString);
+ string activeMultiChannel = string.Join(",", presenceChannels).Replace("-pnpres", "");
+ errorResult.Add(activeMultiChannel.Split(','));
+
+ if (userCallback != null)
+ {
+ GoToCallback<T>(errorResult, userCallback);
+ }
+ LoggingMethod.WriteToLog(string.Format("DateTime {0}, Presence-Subscribe JSON network error response={1}", DateTime.Now.ToString(), jsonString), LoggingMethod.LevelInfo);
+ }
+
}
else
{
@@ -2579,19 +2681,21 @@ private List<object> WrapResultBasedOnResponseType(ResponseType type, string jso
case ResponseType.Subscribe:
case ResponseType.Presence:
result.Add(string.Join(",",channels));
+ long receivedTimetoken = Convert.ToInt64(result[1].ToString());
long minimumTimetoken = (_multiChannelSubscribe.Count > 0) ? _multiChannelSubscribe.Min(token => token.Value) : 0;
long maximumTimetoken = (_multiChannelSubscribe.Count > 0) ? _multiChannelSubscribe.Max(token => token.Value) : 0;
+
if (minimumTimetoken == 0 || lastTimetoken == 0)
{
if (maximumTimetoken == 0)
{
- lastSubscribeTimetoken = Convert.ToInt64(result[1].ToString());
+ lastSubscribeTimetoken = receivedTimetoken;
}
else
{
- if (!enableResumeOnReconnect)
+ if (!_enableResumeOnReconnect)
{
- lastSubscribeTimetoken = Convert.ToInt64(result[1].ToString());
+ lastSubscribeTimetoken = receivedTimetoken;
}
else
{
@@ -2601,7 +2705,21 @@ private List<object> WrapResultBasedOnResponseType(ResponseType type, string jso
}
else
{
- lastSubscribeTimetoken = Convert.ToInt64(result[1].ToString());
+ if (reconnect)
+ {
+ if (_enableResumeOnReconnect)
+ {
+ //do nothing. keep last subscribe token
+ }
+ else
+ {
+ lastSubscribeTimetoken = receivedTimetoken;
+ }
+ }
+ else
+ {
+ lastSubscribeTimetoken = receivedTimetoken;
+ }
}
break;
case ResponseType.Leave:
@@ -2771,6 +2889,44 @@ public void EndPendingRequests()
TerminateReconnectTimer();
}
+ public void TerminateCurrentSubscriberRequest()
+ {
+ string[] channels = GetCurrentSubscriberChannels();
+ if (channels != null)
+ {
+ string multiChannel = string.Join(",", channels);
+ PubnubWebRequest request = (_channelRequest.ContainsKey(multiChannel)) ? _channelRequest[multiChannel] : null;
+ if (request != null)
+ {
+ request.Abort();
+
+ //TerminateHeartbeatTimer(request.RequestUri);
+
+ //TerminateReconnectTimer(multiChannel);
+
+ LoggingMethod.WriteToLog(string.Format("DateTime {0} TerminateCurrentSubsciberRequest {1}", DateTime.Now.ToString(), request.RequestUri.ToString()), LoggingMethod.LevelInfo);
+ }
+ }
+ }
+
+ /// <summary>
+ /// FOR TESTING ONLY - To Enable Simulation of Network Non-Availability
+ /// </summary>
+ public void EnableSimulateNetworkFailForTestingOnly()
+ {
+ ClientNetworkStatus.SimulateNetworkFailForTesting = true;
+ PubnubWebRequest.SimulateNetworkFailForTesting = true;
+ }
+
+ /// <summary>
+ /// FOR TESTING ONLY - To Disable Simulation of Network Non-Availability
+ /// </summary>
+ public void DisableSimulateNetworkFailForTestingOnly()
+ {
+ ClientNetworkStatus.SimulateNetworkFailForTesting = false;
+ PubnubWebRequest.SimulateNetworkFailForTesting = false;
+ }
+
private bool IsPresenceChannel(string channel)
{
if (channel.LastIndexOf("-pnpres") > 0)
@@ -2782,6 +2938,17 @@ private bool IsPresenceChannel(string channel)
return false;
}
}
+
+ private string[] GetCurrentSubscriberChannels()
+ {
+ string[] channels = null;
+ if (_multiChannelSubscribe != null && _multiChannelSubscribe.Keys.Count > 0)
+ {
+ channels = _multiChannelSubscribe.Keys.ToArray<string>();
+ }
+
+ return channels;
+ }
}
/// <summary>
@@ -3580,39 +3747,40 @@ public InternetState()
internal class ClientNetworkStatus
{
private static bool _status = true;
+ private static bool _failClientNetworkForTesting = false;
#if (SILVERLIGHT || WINDOWS_PHONE)
private static ManualResetEvent mres = new ManualResetEvent(false);
private static ManualResetEvent mreSocketAsync = new ManualResetEvent(false);
#else
private static ManualResetEventSlim mres = new ManualResetEventSlim(false);
#endif
- internal static void CheckInternetStatus(bool systemActive, Action<bool> Callback)
+ internal static bool SimulateNetworkFailForTesting
{
- if (Callback != null)
+ get
{
- try
- {
- if (systemActive)
- {
- CheckClientNetworkAvailability(Callback);
- }
- else
- {
- Callback(false);
- }
- }
- catch (Exception ex)
- {
- LoggingMethod.WriteToLog(string.Format("DateTime {0} checkInternetStatus Error. {1}", DateTime.Now.ToString(), ex.ToString()), LoggingMethod.LevelVerbose);
- }
+ return _failClientNetworkForTesting;
}
+
+ set
+ {
+ _failClientNetworkForTesting = value;
+ }
+
}
internal static bool CheckInternetStatus(bool systemActive)
{
- CheckClientNetworkAvailability(CallbackClientNetworkStatus);
- return _status;
+ if (_failClientNetworkForTesting)
+ {
+ //Only to simulate network fail
+ return false;
+ }
+ else
+ {
+ CheckClientNetworkAvailability(CallbackClientNetworkStatus);
+ return _status;
+ }
}
@@ -3810,9 +3978,22 @@ public WebRequest Create(Uri uri)
internal class PubnubWebRequest : WebRequest
{
private IPubnubUnitTest pubnubUnitTest = null;
+ private static bool simulateNetworkFailForTesting = false;
HttpWebRequest request;
+ internal static bool SimulateNetworkFailForTesting
+ {
+ get
+ {
+ return simulateNetworkFailForTesting;
+ }
+ set
+ {
+ simulateNetworkFailForTesting = value;
+ }
+ }
+
#if (!SILVERLIGHT && !WINDOWS_PHONE)
private int _timeout;
public override int Timeout
@@ -3961,6 +4142,11 @@ public override WebResponse EndGetResponse(IAsyncResult asyncResult)
string stubResponse = pubnubUnitTest.GetStubResponse(request.RequestUri);
return new PubnubWebResponse(new MemoryStream(Encoding.UTF8.GetBytes(stubResponse)));
}
+ else if (simulateNetworkFailForTesting)
+ {
+ WebException simulateException = new WebException("For simulating network fail, the remote name could not be resolved", WebExceptionStatus.ConnectFailure);
+ throw simulateException;
+ }
else
{
return new PubnubWebResponse(request.EndGetResponse(asyncResult));
View
0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/AboutResources.txt 100644 → 100755
File mode changed.
View
133 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/Resource.designer.cs 100644 → 100755
@@ -1,3 +1,4 @@
+#pragma warning disable 1591
// ------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
@@ -8,13 +9,25 @@
// </autogenerated>
// ------------------------------------------------------------------------------
+[assembly: Android.Runtime.ResourceDesignerAttribute("PubNubMessaging.Core.Resource", IsApplication=true)]
+
namespace PubNubMessaging.Core
{
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
public partial class Resource
{
+ Resource()
+ {
+ global::Android.Runtime.ResourceIdManager.UpdateIdValues ();
+ }
+
+ public static void UpdateIdValues()
+ {
+ }
+
public partial class Attribute
{
@@ -29,6 +42,9 @@ public partial class Drawable
// aapt resource value: 0x7f020000
public const int Icon = 2130837504;
+ // aapt resource value: 0x7f020001
+ public const int monoandroidsplash = 2130837505;
+
private Drawable()
{
}
@@ -37,80 +53,80 @@ private Drawable()
public partial class Id
{
- // aapt resource value: 0x7f050007
- public const int btnCancel = 2131034119;
+ // aapt resource value: 0x7f060007
+ public const int btnCancel = 2131099655;
- // aapt resource value: 0x7f05000b
- public const int btnDetailedHis = 2131034123;
+ // aapt resource value: 0x7f06000b
+ public const int btnDetailedHis = 2131099659;
- // aapt resource value: 0x7f05000c
- public const int btnHereNow = 2131034124;
+ // aapt resource value: 0x7f06000c
+ public const int btnHereNow = 2131099660;
- // aapt resource value: 0x7f050006
- public const int btnLaunch = 2131034118;
+ // aapt resource value: 0x7f060006
+ public const int btnLaunch = 2131099654;
- // aapt resource value: 0x7f05000a
- public const int btnPresence = 2131034122;
+ // aapt resource value: 0x7f06000a
+ public const int btnPresence = 2131099658;
- // aapt resource value: 0x7f050005
- public const int btnProxy = 2131034117;
+ // aapt resource value: 0x7f060005
+ public const int btnProxy = 2131099653;
- // aapt resource value: 0x7f050018
- public const int btnProxyCancel = 2131034136;
+ // aapt resource value: 0x7f060018
+ public const int btnProxyCancel = 2131099672;
- // aapt resource value: 0x7f050017
- public const int btnProxySave = 2131034135;
+ // aapt resource value: 0x7f060017
+ public const int btnProxySave = 2131099671;
- // aapt resource value: 0x7f050009
- public const int btnPublish = 2131034121;
+ // aapt resource value: 0x7f060009
+ public const int btnPublish = 2131099657;
- // aapt resource value: 0x7f050008
- public const int btnSubscribe = 2131034120;
+ // aapt resource value: 0x7f060008
+ public const int btnSubscribe = 2131099656;
- // aapt resource value: 0x7f05000d
- public const int btnTime = 2131034125;
+ // aapt resource value: 0x7f06000d
+ public const int btnTime = 2131099661;
- // aapt resource value: 0x7f05000e
- public const int btnUnsub = 2131034126;
+ // aapt resource value: 0x7f06000e
+ public const int btnUnsub = 2131099662;
- // aapt resource value: 0x7f05000f
- public const int btnUnsubPres = 2131034127;
+ // aapt resource value: 0x7f06000f
+ public const int btnUnsubPres = 2131099663;
- // aapt resource value: 0x7f050016
- public const int proxyPassword = 2131034134;
+ // aapt resource value: 0x7f060016
+ public const int proxyPassword = 2131099670;
- // aapt resource value: 0x7f050014
- public const int proxyPort = 2131034132;
+ // aapt resource value: 0x7f060014
+ public const int proxyPort = 2131099668;
- // aapt resource value: 0x7f050013
- public const int proxyServer = 2131034131;
+ // aapt resource value: 0x7f060013
+ public const int proxyServer = 2131099667;
- // aapt resource value: 0x7f050015
- public const int proxyUsername = 2131034133;
+ // aapt resource value: 0x7f060015
+ public const int proxyUsername = 2131099669;
- // aapt resource value: 0x7f050010
- public const int scroll = 2131034128;
+ // aapt resource value: 0x7f060010
+ public const int scroll = 2131099664;
- // aapt resource value: 0x7f050012
- public const int tbProxy = 2131034130;
+ // aapt resource value: 0x7f060012
+ public const int tbProxy = 2131099666;
- // aapt resource value: 0x7f050001
- public const int tbSsl = 2131034113;
+ // aapt resource value: 0x7f060001
+ public const int tbSsl = 2131099649;
- // aapt resource value: 0x7f050004
- public const int tvProxy = 2131034116;
+ // aapt resource value: 0x7f060004
+ public const int tvProxy = 2131099652;
- // aapt resource value: 0x7f050000
- public const int txtChannel = 2131034112;
+ // aapt resource value: 0x7f060000
+ public const int txtChannel = 2131099648;
- // aapt resource value: 0x7f050002
- public const int txtCipher = 2131034114;
+ // aapt resource value: 0x7f060002
+ public const int txtCipher = 2131099650;
- // aapt resource value: 0x7f050003
- public const int txtCustomUuid = 2131034115;
+ // aapt resource value: 0x7f060003
+ public const int txtCustomUuid = 2131099651;
- // aapt resource value: 0x7f050011
- public const int txtViewLog = 2131034129;
+ // aapt resource value: 0x7f060011
+ public const int txtViewLog = 2131099665;
private Id()
{
@@ -127,7 +143,10 @@ public partial class Layout
public const int Main = 2130903041;
// aapt resource value: 0x7f030002
- public const int Proxy = 2130903042;
+ public const int monoandroidsplash = 2130903042;
+
+ // aapt resource value: 0x7f030003
+ public const int Proxy = 2130903043;
private Layout()
{
@@ -228,5 +247,17 @@ private String()
{
}
}
+
+ public partial class Style
+ {
+
+ // aapt resource value: 0x7f050000
+ public const int Mono_Android_Theme_Splash = 2131034112;
+
+ private Style()
+ {
+ }
+ }
}
}
+#pragma warning restore 1591
View
0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/drawable/Icon.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/layout-large/Launch.axml 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/layout-large/Main.axml 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/layout/Launch.axml 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/layout/Main.axml 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/layout/Proxy.axml 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/PubNub_Messaging/Resources/values/Strings.xml 100644 → 100755
File mode changed.
View
0 mono-for-android/3.4/Pubnub-Messaging/Pubnub-Messaging.sln 100644 → 100755
File mode changed.
View
18 mono-for-android/3.4/Pubnub-Messaging/Pubnub-Messaging.userprefs 100644 → 100755
@@ -1,23 +1,21 @@
<Properties>
- <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
- <MonoDevelop.Ide.Workbench ActiveDocument="Andr.Unit-master/Andr.Unit/PubnubUnitTest.cs">
+ <MonoDevelop.Ide.Workspace ActiveConfiguration="Release" />
+ <MonoDevelop.Ide.Workbench ActiveDocument="PubNub_Messaging/Pubnub.cs">
<Files>
- <File FileName="PubNub_Messaging/Pubnub.cs" Line="1626" Column="1" />
- <File FileName="Andr.Unit-master/Andr.Unit/PubnubUnitTest.cs" Line="5" Column="28" />
- <File FileName="Andr.Unit-master/Android.NUnitLite/AndrRunner/Activities/TestResultActivity.cs" Line="30" Column="40" />
+ <File FileName="PubNub_Messaging/Pubnub.cs" Line="361" Column="60" />
+ <File FileName="Andr.Unit-master/Android.NUnitLite/AndrRunner/Activities/TestResultActivity.cs" Line="1" Column="1" />
+ <File FileName="Andr.Unit-master/Andr.Unit/PubnubUnitTest.cs" Line="16" Column="4" />
</Files>
<Pads>
<Pad Id="ProjectPad">
<State expanded="True">
- <Node name="Andr.Unit" expanded="True">
- <Node name="PubnubUnitTest.cs" selected="True" />
- </Node>
+ <Node name="Andr.Unit" expanded="True" />
<Node name="Android.NUnitLite" expanded="True">
<Node name="AndrRunner" expanded="True">
<Node name="Activities" expanded="True" />
</Node>
</Node>
- <Node name="PubNubMessaging" expanded="True">
+ <Node name="PubNubMessaging" expanded="True" selected="True">
<Node name="Resources" expanded="True">
<Node name="drawable" expanded="True" />
<Node name="layout" expanded="True" />
@@ -46,6 +44,6 @@
<MonoDevelop.Ide.DebuggingService.PinnedWatches>
<Watch file="PubNub_Messaging/Pubnub.cs" line="1526" offsetX="915" offsetY="22880" expression="cert" liveUpdate="False" />
</MonoDevelop.Ide.DebuggingService.PinnedWatches>
- <MonoDevelop.Ide.ItemProperties.Andr.Unit AndroidDeviceId-Debug="emulator-5554" />
<MonoDevelop.Ide.ItemProperties.PubNubMessaging AndroidDeviceId-Debug="emulator-5554" />
+ <MonoDevelop.Ide.ItemProperties.Andr.Unit AndroidDeviceId-Debug="emulator-5554" />
</Properties>
View
2 mono-for-linux/3.4/Pubnub-Messaging/PubNub-Console/AssemblyInfo.cs 100644 → 100755
@@ -4,7 +4,7 @@
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
-[assembly: AssemblyTitle("PubNub-Console")]
+[assembly: AssemblyTitle("PubNub-Messaging")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
View
0 mono-for-linux/3.4/Pubnub-Messaging/PubNub-Console/PubNub-Messaging.cs 100644 → 100755
File mode changed.
View
13 mono-for-linux/3.4/Pubnub-Messaging/PubNub-Console/PubNub-Messaging.csproj 100644 → 100755
@@ -7,28 +7,28 @@
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{9A973E1B-A9F2-400F-A5DE-C95C085A50EC}</ProjectGuid>
<OutputType>Exe</OutputType>
- <RootNamespace>PubNubMessaging.Core</RootNamespace>
+ <RootNamespace>PubNubConsole</RootNamespace>
<AssemblyName>PubNub-Messaging</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
- <DebugSymbols>true</DebugSymbols>
+ <DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
- <Optimize>false</Optimize>
+ <Optimize>False</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
- <Externalconsole>true</Externalconsole>
+ <Externalconsole>True</Externalconsole>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>none</DebugType>
- <Optimize>true</Optimize>
+ <Optimize>True</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
- <Externalconsole>true</Externalconsole>
+ <Externalconsole>True</Externalconsole>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@@ -43,6 +43,7 @@
<HintPath>Library\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
+ <Reference Include="System.Web" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
View
BIN mono-for-linux/3.4/Pubnub-Messaging/PubNub-Console/PubNub-Messaging.pidb
Binary file not shown.
View
332 mono-for-linux/3.4/Pubnub-Messaging/PubNub-Console/Pubnub.cs 100644 → 100755
@@ -1,5 +1,4 @@
-//Build Date: March 07, 2013
-
+//Build Date: March 16, 2013
#if (__MonoCS__)
#define TRACE
#endif
@@ -38,17 +37,18 @@
using System.Security.Cryptography.X509Certificates;
#endif
+
namespace PubNubMessaging.Core
{
// INotifyPropertyChanged provides a standard event for objects to notify clients that one of its properties has changed
public class Pubnub : INotifyPropertyChanged
{
- const int pubnubWebRequestCallbackIntervalInSeconds = 310;
- const int pubnubOperationTimeoutIntervalInSeconds = 15;
- const int pubnubNetworkTcpCheckIntervalInSeconds = 15;
- const int pubnubNetworkCheckRetries = 50;
- const int pubnubWebRequestRetryIntervalInSeconds = 10;
- bool enableResumeOnReconnect = true;
+ int _pubnubWebRequestCallbackIntervalInSeconds = 310;
+ int _pubnubOperationTimeoutIntervalInSeconds = 15;
+ int _pubnubNetworkTcpCheckIntervalInSeconds = 15;
+ int _pubnubNetworkCheckRetries = 50;
+ int _pubnubWebRequestRetryIntervalInSeconds = 10;
+ bool _enableResumeOnReconnect = true;
bool overrideTcpKeepAlive = true;
const LoggingMethod.Level pubnubLogLevel = LoggingMethod.Level.Error;
@@ -76,6 +76,83 @@ public void RaisePropertyChanged(string propertyName)
ConcurrentDictionary<string, Timer> _channelReconnectTimer = new ConcurrentDictionary<string, Timer>();
ConcurrentDictionary<Uri, Timer> _channelHeartbeatTimer = new ConcurrentDictionary<Uri, Timer>();
+ internal int SubscribeTimeout
+ {
+ get
+ {
+ return _pubnubWebRequestCallbackIntervalInSeconds;
+ }
+
+ set
+ {
+ _pubnubWebRequestCallbackIntervalInSeconds = value;
+ }
+ }
+
+ internal int NonSubscribeTimeout
+ {
+ get
+ {
+ return _pubnubOperationTimeoutIntervalInSeconds;
+ }
+
+ set
+ {
+ _pubnubOperationTimeoutIntervalInSeconds = value;
+ }
+ }
+
+ internal int NetworkCheckMaxRetries
+ {
+ get
+ {
+ return _pubnubNetworkCheckRetries;
+ }
+
+ set
+ {
+ _pubnubNetworkCheckRetries = value;
+ }
+ }
+
+ internal int NetworkCheckRetryInterval
+ {
+ get
+ {
+ return _pubnubWebRequestRetryIntervalInSeconds;
+ }
+
+ set
+ {
+ _pubnubWebRequestRetryIntervalInSeconds = value;
+ }
+ }
+
+ internal int HeartbeatInterval
+ {
+ get
+ {
+ return _pubnubNetworkTcpCheckIntervalInSeconds;
+ }
+
+ set
+ {
+ _pubnubNetworkTcpCheckIntervalInSeconds = value;
+ }
+ }
+
+ internal bool EnableResumeOnReconnect
+ {
+ get
+ {
+ return _enableResumeOnReconnect;
+ }
+ set
+ {
+ _enableResumeOnReconnect = value;
+ }
+ }
+
private IPubnubUnitTest _pubnubUnitTest;
public IPubnubUnitTest PubnubUnitTest
{
@@ -197,7 +274,7 @@ private void Init(string publishKey, string subscribeKey, string secretKey, stri
private void ReconnectNetwork<T>(ReconnectState<T> netState)
{
- System.Threading.Timer timer = new Timer(new TimerCallback(ReconnectNetworkCallback<T>), netState, 0, pubnubNetworkTcpCheckIntervalInSeconds * 1000);
+ System.Threading.Timer timer = new Timer(new TimerCallback(ReconnectNetworkCallback<T>), netState, 0, _pubnubNetworkTcpCheckIntervalInSeconds * 1000);
_channelReconnectTimer.AddOrUpdate(string.Join(",",netState.Channels), timer, (key, oldState) => timer);
}
@@ -222,7 +299,7 @@ void ReconnectNetworkCallback<T>(Object reconnectState)
else
{
_channelInternetRetry.AddOrUpdate(channel, 1, (key, oldValue) => oldValue + 1);
- LoggingMethod.WriteToLog(string.Format("DateTime {0}, {1} {2} reconnectNetworkCallback. Retry {3} of {4}", DateTime.Now.ToString(), channel, netState.Type, _channelInternetRetry[channel], pubnubNetworkCheckRetries), LoggingMethod.LevelInfo);
+ LoggingMethod.WriteToLog(string.Format("DateTime {0}, {1} {2} reconnectNetworkCallback. Retry {3} of {4}", DateTime.Now.ToString(), channel, netState.Type, _channelInternetRetry[channel], _pubnubNetworkCheckRetries), LoggingMethod.LevelInfo);
}
}
@@ -245,7 +322,7 @@ void ReconnectNetworkCallback<T>(Object reconnectState)
break;
}
}
- else if (_channelInternetRetry[channel] >= pubnubNetworkCheckRetries)
+ else if (_channelInternetRetry[channel] >= _pubnubNetworkCheckRetries)
{
if (_channelReconnectTimer.ContainsKey(channel))
{
@@ -316,8 +393,8 @@ void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
if (overrideTcpKeepAlive)
{
heartBeatTimer.Change(
- (-1 == pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : pubnubNetworkTcpCheckIntervalInSeconds * 1000,
- (-1 == pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : pubnubNetworkTcpCheckIntervalInSeconds * 1000);
+ (-1 == _pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : _pubnubNetworkTcpCheckIntervalInSeconds * 1000,
+ (-1 == _pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : _pubnubNetworkTcpCheckIntervalInSeconds * 1000);
}
LoggingMethod.WriteToLog(string.Format("DateTime {0}, System entered into Resume/Awake Mode.", DateTime.Now.ToString()), LoggingMethod.LevelInfo);
@@ -1076,7 +1153,7 @@ private void MultiChannelSubscribeRequest<T>(ResponseType type, string[] channel
if (_channelInternetStatus.ContainsKey(multiChannel) && (!_channelInternetStatus[multiChannel]) && _pubnetSystemActive)
{
- if (_channelInternetRetry.ContainsKey(multiChannel) && (_channelInternetRetry[multiChannel] >= pubnubNetworkCheckRetries))
+ if (_channelInternetRetry.ContainsKey(multiChannel) && (_channelInternetRetry[multiChannel] >= _pubnubNetworkCheckRetries))
{
LoggingMethod.WriteToLog(string.Format("DateTime {0}, Subscribe channel={1} - No internet connection. MAXed retries for internet ", DateTime.Now.ToString(), multiChannel), LoggingMethod.LevelInfo);
MultiplexExceptionHandler<T>(type,channels, userCallback, connectCallback, true, false);
@@ -1121,7 +1198,6 @@ private void MultiChannelSubscribeRequest<T>(ResponseType type, string[] channel
lastTimetoken = lastSubscribeTimetoken;
}
}
-
LoggingMethod.WriteToLog(string.Format("DateTime {0}, Building request for channel(s)={1} with timetoken={2}", DateTime.Now.ToString(), string.Join(",",channels),lastTimetoken), LoggingMethod.LevelInfo);
// Build URL
Uri requestUrl = BuildMultiChannelSubscribeRequest(channels, (Convert.ToInt64(timetoken.ToString()) == 0) ? Convert.ToInt64(timetoken.ToString()) : lastTimetoken);
@@ -1362,13 +1438,13 @@ private bool UrlProcessRequest<T>(Uri requestUri, RequestState<T> pubnubRequestS
//Eventhough heart-beat is disabled, run one time to check internet connection by setting dueTime=0
heartBeatTimer = new System.Threading.Timer(
new TimerCallback(OnPubnubHeartBeatTimeoutCallback<T>), pubnubRequestState, 0,
- (-1 == pubnubNetworkTcpCheckIntervalInSeconds) ? Timeout.Infinite : pubnubNetworkTcpCheckIntervalInSeconds * 1000);
+ (-1 == _pubnubNetworkTcpCheckIntervalInSeconds) ? Timeout.Infinite : _pubnubNetworkTcpCheckIntervalInSeconds * 1000);
_channelHeartbeatTimer.AddOrUpdate(requestUri, heartBeatTimer, (key, oldState) => heartBeatTimer);
}
else
{
#if ((!__MonoCS__) && (!SILVERLIGHT) && !WINDOWS_PHONE)
- request.ServicePoint.SetTcpKeepAlive(true, pubnubNetworkTcpCheckIntervalInSeconds * 1000, 1000);
+ request.ServicePoint.SetTcpKeepAlive(true, _pubnubNetworkTcpCheckIntervalInSeconds * 1000, 1000);
#endif
}
LoggingMethod.WriteToLog(string.Format("DateTime {0}, Request={1}", DateTime.Now.ToString(), requestUri.ToString()), LoggingMethod.LevelInfo);
@@ -1570,7 +1646,8 @@ void ConnectToHostAndSendRequest<T>(bool sslEnabled, TcpClient tcpClient, Reques
throw new Exception("SSL error");
}
}
-#endif
+#endif
+
private void ConnectToHostAndSendRequestCallback<T>(IAsyncResult asynchronousResult)
{
StateObject<T> asynchStateObject = asynchronousResult.AsyncState as StateObject<T>;
@@ -1694,7 +1771,6 @@ private void SendRequestUsingTcpClient<T>(Uri requestUri, RequestState<T> pubnub
{
TcpClient tcpClient = new TcpClient();
tcpClient.NoDelay = false;
-
#if(!MONODROID)
tcpClient.SendTimeout = pubnubRequestState.Request.Timeout;
#endif
@@ -1870,11 +1946,11 @@ void ProcessResponseCallbackWebExceptionHandler<T>(WebException webEx, RequestSt
else
{
_channelInternetRetry.AddOrUpdate(channel, 1, (key, oldValue) => oldValue + 1);
- LoggingMethod.WriteToLog(string.Format("DateTime {0} {1} channel = {2} _urlRequest - Internet connection retry {3} of {4}", DateTime.Now.ToString(), asynchRequestState.Type, string.Join(",", asynchRequestState.Channels), _channelInternetRetry[channel], pubnubNetworkCheckRetries), LoggingMethod.LevelInfo);
+ LoggingMethod.WriteToLog(string.Format("DateTime {0} {1} channel = {2} _urlRequest - Internet connection retry {3} of {4}", DateTime.Now.ToString(), asynchRequestState.Type, string.Join(",", asynchRequestState.Channels), _channelInternetRetry[channel], _pubnubNetworkCheckRetries), LoggingMethod.LevelInfo);
}
_channelInternetStatus[channel] = false;
- Thread.Sleep(pubnubWebRequestRetryIntervalInSeconds * 1000);
+ Thread.Sleep(_pubnubWebRequestRetryIntervalInSeconds * 1000);
}
}
#endif
@@ -1984,11 +2060,11 @@ private int GetTimeoutInSecondsForResponseType(ResponseType type)
int timeout;
if (type == ResponseType.Subscribe || type == ResponseType.Presence)
{
- timeout = pubnubWebRequestCallbackIntervalInSeconds;
+ timeout = _pubnubWebRequestCallbackIntervalInSeconds;
}
else
{
- timeout = pubnubOperationTimeoutIntervalInSeconds;
+ timeout = _pubnubOperationTimeoutIntervalInSeconds;
}
return timeout;
}
@@ -2010,8 +2086,8 @@ private void TerminateHeartbeatTimer(Uri requestUri)
try
{
requestHeatbeatTimer.Change(
- (-1 == pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : pubnubNetworkTcpCheckIntervalInSeconds * 1000,
- (-1 == pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : pubnubNetworkTcpCheckIntervalInSeconds * 1000);
+ (-1 == _pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : _pubnubNetworkTcpCheckIntervalInSeconds * 1000,
+ (-1 == _pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : _pubnubNetworkTcpCheckIntervalInSeconds * 1000);
requestHeatbeatTimer.Dispose();
}
catch (ObjectDisposedException ex)
@@ -2066,8 +2142,8 @@ private void TerminateReconnectTimer(string channelName)
{
Timer channelReconnectTimer = _channelReconnectTimer[channelName];
channelReconnectTimer.Change(
- (-1 == pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : pubnubNetworkTcpCheckIntervalInSeconds * 1000,
- (-1 == pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : pubnubNetworkTcpCheckIntervalInSeconds * 1000);
+ (-1 == _pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : _pubnubNetworkTcpCheckIntervalInSeconds * 1000,
+ (-1 == _pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : _pubnubNetworkTcpCheckIntervalInSeconds * 1000);
channelReconnectTimer.Dispose();
Timer removedTimer = null;
bool removed = _channelReconnectTimer.TryRemove(channelName, out removedTimer);
@@ -2109,22 +2185,28 @@ private void ResponseToConnectCallback<T>(List<object> result, ResponseType type
select channel.Key;
foreach (string channel in newChannels)
{
- if (!IsPresenceChannel(channel))
+ string jsonString = "";
+ List<object> connectResult = new List<object>();
+ //if (!IsPresenceChannel(channel))
+ //{
+ switch (type)
{
- switch (type)
- {
- case ResponseType.Subscribe:
- string jsonString = "";
- List<object> connectResult = new List<object>();
- jsonString = string.Format("[1, \"Connected\"]");
- connectResult = (List<object>)JsonConvert.DeserializeObject<List<object>>(jsonString);
- connectResult.Add(channel);
- GoToCallback<T>(connectResult, connectCallback);
- break;
- default:
- break;
- }
+ case ResponseType.Subscribe:
+ jsonString = string.Format("[1, \"Connected\"]");
+ connectResult = (List<object>)JsonConvert.DeserializeObject<List<object>>(jsonString);
+ connectResult.Add(channel);
+ GoToCallback<T>(connectResult, connectCallback);
+ break;
+ case ResponseType.Presence:
+ jsonString = string.Format("[1, \"Presence Connected\"]");
+ connectResult = (List<object>)JsonConvert.DeserializeObject<List<object>>(jsonString);
+ connectResult.Add(channel.Replace("-pnpres", ""));
+ GoToCallback<T>(connectResult, connectCallback);
+ break;
+ default:
+ break;
}
+ //}
}
}
@@ -2452,18 +2534,38 @@ private void MultiplexExceptionHandler<T>(ResponseType type, string[] channels,
string[] activeChannels = _multiChannelSubscribe.Keys.ToArray<string>();
MultiChannelUnSubscribeInit<T>(ResponseType.Unsubscribe, string.Join(",", activeChannels), null, null, null);
- List<object> errorResult = new List<object>();
- string jsonString = string.Format("[0, \"Unsubscribed after {0} failed retries\"]", pubnubNetworkCheckRetries);
- errorResult = (List<object>)JsonConvert.DeserializeObject<List<object>>(jsonString);
- string activeMultiChannel = string.Join(",", activeChannels).Replace("-pnpres", "");
- errorResult.Add(activeMultiChannel.Split(','));
-
- LoggingMethod.WriteToLog(string.Format("DateTime {0}, Subscribe JSON network error response={1}", DateTime.Now.ToString(), jsonString), LoggingMethod.LevelInfo);
+ string[] subscribeChannels = activeChannels.Where(filterChannel => !filterChannel.Contains("-pnpres")).ToArray();
+ string[] presenceChannels = activeChannels.Where(filterChannel => filterChannel.Contains("-pnpres")).ToArray();
- if (userCallback != null)
+ if (subscribeChannels != null && subscribeChannels.Length > 0)
{
- GoToCallback<T>(errorResult, userCallback);
+ List<object> errorResult = new List<object>();
+ string jsonString = string.Format("[0, \"Unsubscribed after {0} failed retries\"]", _pubnubNetworkCheckRetries);
+ errorResult = (List<object>)JsonConvert.DeserializeObject<List<object>>(jsonString);
+ string activeMultiChannel = string.Join(",", subscribeChannels);
+ errorResult.Add(activeMultiChannel.Split(','));
+
+ if (userCallback != null)
+ {
+ GoToCallback<T>(errorResult, userCallback);
+ }
+ LoggingMethod.WriteToLog(string.Format("DateTime {0}, Subscribe JSON network error response={1}", DateTime.Now.ToString(), jsonString), LoggingMethod.LevelInfo);
}
+ if (presenceChannels != null && presenceChannels.Length > 0)
+ {
+ List<object> errorResult = new List<object>();
+ string jsonString = string.Format("[0, \"Presence Unsubscribed after {0} failed retries\"]", _pubnubNetworkCheckRetries);
+ errorResult = (List<object>)JsonConvert.DeserializeObject<List<object>>(jsonString);
+ string activeMultiChannel = string.Join(",", presenceChannels).Replace("-pnpres", "");
+ errorResult.Add(activeMultiChannel.Split(','));
+
+ if (userCallback != null)
+ {
+ GoToCallback<T>(errorResult, userCallback);
+ }
+ LoggingMethod.WriteToLog(string.Format("DateTime {0}, Presence-Subscribe JSON network error response={1}", DateTime.Now.ToString(), jsonString), LoggingMethod.LevelInfo);
+ }
+
}
else
{
@@ -2579,19 +2681,21 @@ private List<object> WrapResultBasedOnResponseType(ResponseType type, string jso
case ResponseType.Subscribe:
case ResponseType.Presence:
result.Add(string.Join(",",channels));
+ long receivedTimetoken = Convert.ToInt64(result[1].ToString());
long minimumTimetoken = (_multiChannelSubscribe.Count > 0) ? _multiChannelSubscribe.Min(token => token.Value) : 0;
long maximumTimetoken = (_multiChannelSubscribe.Count > 0) ? _multiChannelSubscribe.Max(token => token.Value) : 0;
+
if (minimumTimetoken == 0 || lastTimetoken == 0)
{
if (maximumTimetoken == 0)
{
- lastSubscribeTimetoken = Convert.ToInt64(result[1].ToString());
+ lastSubscribeTimetoken = receivedTimetoken;
}
else
{
- if (!enableResumeOnReconnect)
+ if (!_enableResumeOnReconnect)
{
- lastSubscribeTimetoken = Convert.ToInt64(result[1].ToString());
+ lastSubscribeTimetoken = receivedTimetoken;
}
else
{
@@ -2601,7 +2705,21 @@ private List<object> WrapResultBasedOnResponseType(ResponseType type, string jso
}
else
{
- lastSubscribeTimetoken = Convert.ToInt64(result[1].ToString());
+ if (reconnect)
+ {
+ if (_enableResumeOnReconnect)
+ {
+ //do nothing. keep last subscribe token
+ }
+ else
+ {
+ lastSubscribeTimetoken = receivedTimetoken;
+ }
+ }
+ else
+ {
+ lastSubscribeTimetoken = receivedTimetoken;
+ }
}
break;
case ResponseType.Leave:
@@ -2771,6 +2889,44 @@ public void EndPendingRequests()
TerminateReconnectTimer();
}
+ public void TerminateCurrentSubscriberRequest()
+ {
+ string[] channels = GetCurrentSubscriberChannels();
+ if (channels != null)
+ {
+ string multiChannel = string.Join(",", channels);
+ PubnubWebRequest request = (_channelRequest.ContainsKey(multiChannel)) ? _channelRequest[multiChannel] : null;
+ if (request != null)
+ {
+ request.Abort();
+
+ //TerminateHeartbeatTimer(request.RequestUri);
+
+ //TerminateReconnectTimer(multiChannel);
+
+ LoggingMethod.WriteToLog(string.Format("DateTime {0} TerminateCurrentSubsciberRequest {1}", DateTime.Now.ToString(), request.RequestUri.ToString()), LoggingMethod.LevelInfo);
+ }
+ }
+ }
+
+ /// <summary>
+ /// FOR TESTING ONLY - To Enable Simulation of Network Non-Availability
+ /// </summary>
+ public void EnableSimulateNetworkFailForTestingOnly()
+ {
+ ClientNetworkStatus.SimulateNetworkFailForTesting = true;
+ PubnubWebRequest.SimulateNetworkFailForTesting = true;
+ }
+
+ /// <summary>
+ /// FOR TESTING ONLY - To Disable Simulation of Network Non-Availability
+ /// </summary>
+ public void DisableSimulateNetworkFailForTestingOnly()
+ {
+ ClientNetworkStatus.SimulateNetworkFailForTesting = false;
+ PubnubWebRequest.SimulateNetworkFailForTesting = false;
+ }
+
private bool IsPresenceChannel(string channel)
{
if (channel.LastIndexOf("-pnpres") > 0)
@@ -2782,6 +2938,17 @@ private bool IsPresenceChannel(string channel)
return false;
}
}
+
+ private string[] GetCurrentSubscriberChannels()
+ {
+ string[] channels = null;
+ if (_multiChannelSubscribe != null && _multiChannelSubscribe.Keys.Count > 0)
+ {
+ channels = _multiChannelSubscribe.Keys.ToArray<string>();
+ }
+
+ return channels;
+ }
}
/// <summary>
@@ -3580,39 +3747,40 @@ public InternetState()
internal class ClientNetworkStatus
{
private static bool _status = true;
+ private static bool _failClientNetworkForTesting = false;
#if (SILVERLIGHT || WINDOWS_PHONE)
private static ManualResetEvent mres = new ManualResetEvent(false);
private static ManualResetEvent mreSocketAsync = new ManualResetEvent(false);
#else
private static ManualResetEventSlim mres = new ManualResetEventSlim(false);
#endif
- internal static void CheckInternetStatus(bool systemActive, Action<bool> Callback)
+ internal static bool SimulateNetworkFailForTesting
{
- if (Callback != null)
+ get
{
- try
- {
- if (systemActive)
- {
- CheckClientNetworkAvailability(Callback);
- }
- else
- {
- Callback(false);
- }
- }
- catch (Exception ex)
- {
- LoggingMethod.WriteToLog(string.Format("DateTime {0} checkInternetStatus Error. {1}", DateTime.Now.ToString(), ex.ToString()), LoggingMethod.LevelVerbose);
- }
+ return _failClientNetworkForTesting;
}
+
+ set
+ {
+ _failClientNetworkForTesting = value;
+ }
+
}
internal static bool CheckInternetStatus(bool systemActive)
{
- CheckClientNetworkAvailability(CallbackClientNetworkStatus);
- return _status;
+ if (_failClientNetworkForTesting)
+ {
+ //Only to simulate network fail
+ return false;
+ }
+ else
+ {
+ CheckClientNetworkAvailability(CallbackClientNetworkStatus);
+ return _status;
+ }
}
@@ -3810,9 +3978,22 @@ public WebRequest Create(Uri uri)
internal class PubnubWebRequest : WebRequest
{
private IPubnubUnitTest pubnubUnitTest = null;
+ private static bool simulateNetworkFailForTesting = false;
HttpWebRequest request;
+ internal static bool SimulateNetworkFailForTesting
+ {
+ get
+ {
+ return simulateNetworkFailForTesting;
+ }
+ set
+ {
+ simulateNetworkFailForTesting = value;
+ }
+ }
+
#if (!SILVERLIGHT && !WINDOWS_PHONE)
private int _timeout;
public override int Timeout
@@ -3961,6 +4142,11 @@ public override WebResponse EndGetResponse(IAsyncResult asyncResult)
string stubResponse = pubnubUnitTest.GetStubResponse(request.RequestUri);
return new PubnubWebResponse(new MemoryStream(Encoding.UTF8.GetBytes(stubResponse)));
}
+ else if (simulateNetworkFailForTesting)
+ {
+ WebException simulateException = new WebException("For simulating network fail, the remote name could not be resolved", WebExceptionStatus.ConnectFailure);
+ throw simulateException;
+ }
else
{
return new PubnubWebResponse(request.EndGetResponse(asyncResult));
View
699 mono-for-linux/3.4/Pubnub-Messaging/PubNub-Console/PubnubExample.cs 100644 → 100755
@@ -7,277 +7,430 @@
namespace PubNubMessaging.Core
{
- public class PubnubExample
- {
- static public Pubnub pubnub;
-
- static public bool deliveryStatus = false;
- static public string channel = "";
-
- static public void Main()
- {
- 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("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("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.WriteLine("Accepted Custom Session UUID.");
- }
- else
- {
- Console.WriteLine("Default Session UUID opted.");
- }
- Console.WriteLine();
-
-
- Console.WriteLine("Proxy Server exists? ENTER Y for Yes, else N");
- 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;
- try
- {
- pubnub.Proxy = proxy;
- proxyAccepted = true;
- Console.WriteLine("Proxy details accepted");
- }
- catch (MissingFieldException mse)
- {
- Console.WriteLine(mse.Message);
- Console.WriteLine("Please RE-ENTER Proxy Server details.");
- }
- }
- }
- else
- {
- Console.WriteLine("No Proxy");
- }
- Console.WriteLine();
-
-
- 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;
- string channel="";
-
- Console.WriteLine("");
- while (!exitFlag)
- {
- string userinput = Console.ReadLine();
- switch (userinput)
- {
- case "0":
- exitFlag = true;
- pubnub.EndPendingRequests();
- break;
- case "1":
- Console.WriteLine("Enter CHANNEL name for subscribe. Use comma to enter multiple channels.");
- channel = Console.ReadLine();
-
- Console.WriteLine(string.Format("Channel = {0}",channel));
- Console.WriteLine();
-
- Console.WriteLine("Running subscribe()");
- pubnub.Subscribe<string>(channel, DisplayReturnMessage, DisplayConnectStatusMessage);
-
- break;
- case "2":
- Console.WriteLine("Enter CHANNEL name for publish.");
- channel = Console.ReadLine();
-
- Console.WriteLine("Enter the message for publish. To exit loop, enter QUIT");
- string publishMsg = Console.ReadLine();
-
- Console.WriteLine("Running publish()");
-
- 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 "3":
- Console.WriteLine("Enter CHANNEL name for presence. Use comma to enter multiple channels.");
- channel = Console.ReadLine();
-
- Console.WriteLine(string.Format("Presence Channel = {0}",channel));
- Console.WriteLine();
-
- Console.WriteLine("Running presence()");
- pubnub.Presence<string>(channel, DisplayReturnMessage, null);
-
- break;
- case "4":
- Console.WriteLine("Enter CHANNEL name for Detailed History");
- channel = Console.ReadLine();
-
- Console.WriteLine(string.Format("Channel = {0}",channel));
- Console.WriteLine();
-
- Console.WriteLine("Running detailed history()");
- pubnub.DetailedHistory<string>(channel, 100, DisplayReturnMessage);
- break;
- case "5":
- Console.WriteLine("Enter CHANNEL name for HereNow");
- channel = Console.ReadLine();
-
- Console.WriteLine(string.Format("Channel = {0}",channel));
- Console.WriteLine();
-
- Console.WriteLine("Running Here_Now()");
- pubnub.HereNow<string>(channel, DisplayReturnMessage);
- break;
- case "6":
- Console.WriteLine("Enter CHANNEL name for Unsubscribe. Use comma to enter multiple channels.");
- channel = Console.ReadLine();
-
- Console.WriteLine(string.Format("Channel = {0}",channel));
- Console.WriteLine();
-
- Console.WriteLine("Running unsubscribe()");
- pubnub.Unsubscribe<string>(channel, DisplayReturnMessage, DisplayConnectStatusMessage, DisplayDisconnectStatusMessage);
- break;
- case "7":
- Console.WriteLine("Enter CHANNEL name for Presence Unsubscribe. Use comma to enter multiple channels.");
- channel = Console.ReadLine();
-
- Console.WriteLine(string.Format("Channel = {0}",channel));
- Console.WriteLine();
-
- Console.WriteLine("Running presence-unsubscribe()");
- pubnub.PresenceUnsubscribe<string>(channel, DisplayReturnMessage, DisplayConnectStatusMessage, DisplayDisconnectStatusMessage);
- break;
- case "8":
- 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();
-
- }