rhoconnect 3.3.6 → 3.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. data/CHANGELOG.md +40 -4
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +27 -25
  4. data/bench/benchapp/Gemfile +7 -27
  5. data/bench/benchapp/config.ru +9 -31
  6. data/bench/blobapp/Gemfile +7 -27
  7. data/bench/blobapp/config.ru +9 -29
  8. data/bench/lib/bench.rb +8 -1
  9. data/bench/lib/bench/test_data.rb +4 -1
  10. data/bench/scripts/blob_cud_script.rb +4 -0
  11. data/bench/scripts/cud_script.rb +7 -1
  12. data/bench/scripts/helpers.rb +1 -1
  13. data/bench/scripts/test_query_script.rb +20 -7
  14. data/bench/spec/bench_spec_helper.rb +3 -1
  15. data/bin/rhoconnect +22 -12
  16. data/commands/{commands/dtach_commands → dtach}/dtach_about.rb +0 -0
  17. data/commands/{commands/dtach_commands → dtach}/dtach_install.rb +0 -0
  18. data/commands/{commands/redis_commands → dtach}/redis_attach.rb +0 -0
  19. data/commands/execute.rb +14 -15
  20. data/commands/generators/update.rb +26 -0
  21. data/commands/{commands/redis_commands → redis}/redis_about.rb +0 -0
  22. data/commands/redis/redis_download.rb +13 -0
  23. data/commands/redis/redis_install.rb +26 -0
  24. data/commands/{commands/redis_commands → redis}/redis_make.rb +0 -0
  25. data/commands/{commands/redis_commands → redis}/redis_restart.rb +3 -2
  26. data/commands/{commands/redis_commands → redis}/redis_start.rb +0 -0
  27. data/commands/{commands/redis_commands → redis}/redis_startbg.rb +0 -0
  28. data/commands/{commands/redis_commands → redis}/redis_stop.rb +3 -2
  29. data/commands/{commands/rhoconnect → rhoconnect}/clean_start.rb +0 -0
  30. data/commands/{commands/rhoconnect → rhoconnect}/config.rb +7 -2
  31. data/commands/{commands/rhoconnect → rhoconnect}/create_user.rb +0 -0
  32. data/commands/{commands/rhoconnect → rhoconnect}/delete_device.rb +0 -0
  33. data/commands/{commands/rhoconnect → rhoconnect}/delete_user.rb +0 -0
  34. data/commands/{commands/rhoconnect → rhoconnect}/flushdb.rb +4 -4
  35. data/commands/{commands/rhoconnect → rhoconnect}/get_token.rb +0 -0
  36. data/commands/{commands/rhoconnect → rhoconnect}/reset.rb +0 -0
  37. data/commands/{commands/rhoconnect → rhoconnect}/reset_refresh.rb +0 -0
  38. data/commands/{commands/rhoconnect → rhoconnect}/restart.rb +0 -0
  39. data/commands/{commands/rhoconnect → rhoconnect}/secret.rb +0 -0
  40. data/commands/{commands/rhoconnect → rhoconnect}/set_admin_password.rb +0 -0
  41. data/commands/{commands/rhoconnect → rhoconnect}/spec.rb +0 -0
  42. data/commands/rhoconnect/start.rb +27 -0
  43. data/commands/{commands/rhoconnect → rhoconnect}/startbg.rb +0 -0
  44. data/commands/{commands/rhoconnect → rhoconnect}/startdebug.rb +2 -2
  45. data/commands/{commands/rhoconnect → rhoconnect}/stop.rb +3 -4
  46. data/commands/{commands/rhoconnect → rhoconnect}/version.rb +0 -0
  47. data/commands/{commands/rhoconnect → rhoconnect}/web.rb +0 -0
  48. data/commands/rhoconnect_attach/attach.rb +10 -0
  49. data/commands/rhoconnect_console/console.rb +16 -0
  50. data/commands/{commands/rhoconnect → rhoconnect_console}/console_helper.rb +0 -0
  51. data/commands/{commands/rhoconnect → rhoconnect_war}/war.rb +0 -0
  52. data/commands/{commands/redis_commands → utilities}/redis_runner.rb +22 -19
  53. data/commands/utilities/utilities.rb +6 -0
  54. data/doc/benchmarks.txt +2 -2
  55. data/doc/bulk-sync.txt +12 -1
  56. data/doc/client-java.txt +3 -3
  57. data/doc/client-objc.txt +1 -1
  58. data/doc/client.txt +5 -5
  59. data/doc/command-line.txt +80 -135
  60. data/doc/deploying.txt +119 -12
  61. data/doc/extending-rhoconnect-server.txt +1 -1
  62. data/doc/heroku-addon.txt +119 -23
  63. data/doc/install.txt +101 -39
  64. data/doc/java-plugin.txt +2 -2
  65. data/doc/licensing.txt +1 -1
  66. data/doc/plugin-intro.txt +3 -1
  67. data/doc/preparing-production.txt +4 -4
  68. data/doc/public/cli.txt +2 -2
  69. data/doc/push-backend-setup.txt +11 -1
  70. data/doc/push-client-setup.txt +72 -2
  71. data/doc/push-server-setup.txt +129 -8
  72. data/doc/rails-plugin.txt +245 -40
  73. data/doc/rest-api.txt +10 -6
  74. data/doc/rhoconnect-calculator.txt +237 -0
  75. data/doc/rhoconnect-redis-stack.txt +35 -0
  76. data/doc/session-and-configuration.txt +24 -0
  77. data/doc/settings.txt +51 -41
  78. data/doc/source-adapters.txt +45 -45
  79. data/doc/stats-middleware.txt +2 -2
  80. data/doc/supported-platforms.txt +6 -6
  81. data/doc/testing.txt +2 -2
  82. data/doc/tutorial.txt +63 -63
  83. data/examples/simple/Gemfile +7 -35
  84. data/examples/simple/config.ru +8 -26
  85. data/examples/simple/sources/product.rb +6 -6
  86. data/generators/rhoconnect.rb +5 -0
  87. data/generators/templates/application/Gemfile +7 -37
  88. data/generators/templates/application/Rakefile +8 -0
  89. data/generators/templates/application/config.ru +12 -31
  90. data/generators/templates/application/rcgemfile +44 -0
  91. data/generators/templates/application/settings/settings.yml +7 -5
  92. data/install.sh +4 -4
  93. data/installer/unix-like/create_texts.rb +7 -2
  94. data/installer/unix-like/rho_connect_install_constants.rb +2 -2
  95. data/installer/unix-like/rho_connect_install_installers.rb +1 -16
  96. data/lib/rhoconnect.rb +51 -38
  97. data/lib/rhoconnect/api/app/query.rb +4 -1
  98. data/lib/rhoconnect/api/app/search.rb +4 -1
  99. data/lib/rhoconnect/api/client/list_client_docs.rb +3 -1
  100. data/lib/rhoconnect/api/user/ping.rb +1 -5
  101. data/lib/rhoconnect/application/init.rb +43 -0
  102. data/lib/rhoconnect/async.rb +11 -6
  103. data/lib/rhoconnect/client_sync.rb +30 -37
  104. data/lib/rhoconnect/document.rb +4 -0
  105. data/lib/rhoconnect/graph_helper.rb +74 -56
  106. data/lib/rhoconnect/middleware/helpers.rb +4 -0
  107. data/lib/rhoconnect/ping.rb +1 -0
  108. data/lib/rhoconnect/ping/gcm.rb +58 -0
  109. data/lib/rhoconnect/predefined_adapters/bench_adapter.rb +7 -1
  110. data/lib/rhoconnect/source.rb +70 -56
  111. data/lib/rhoconnect/source_sync.rb +33 -5
  112. data/lib/rhoconnect/store.rb +358 -110
  113. data/lib/rhoconnect/user.rb +8 -0
  114. data/lib/rhoconnect/utilities.rb +16 -14
  115. data/lib/rhoconnect/version.rb +1 -1
  116. data/lib/rhoconnect/web-console/models/client.js +1 -1
  117. data/lib/rhoconnect/web-console/public/UNVR67bold.ttf +0 -0
  118. data/lib/rhoconnect/web-console/public/bootstrap.css +6 -0
  119. data/lib/rhoconnect/web-console/public/logo.png +0 -0
  120. data/lib/rhoconnect/web-console/server.rb +13 -11
  121. data/lib/rhoconnect/web-console/templates/index.erb +5 -5
  122. data/lib/rhoconnect/web-console/templates/jqplot.erb +1 -0
  123. data/lib/rhoconnect/web-console/views/doc.js +0 -4
  124. data/lib/rhoconnect/web-console/views/home.js +2 -1
  125. data/lib/rhoconnect/web-console/views/new_ping.js +11 -6
  126. data/lib/rhoconnect/web-console/views/stats.js +9 -5
  127. data/rhoconnect.gemspec +6 -4
  128. data/spec/api/app/fast_update_spec.rb +2 -2
  129. data/spec/api/source/get_source_params_spec.rb +1 -0
  130. data/spec/apps/rhotestapp/settings/settings.yml +5 -5
  131. data/spec/client_sync_spec.rb +3 -14
  132. data/spec/perf/perf_spec_helper.rb +11 -7
  133. data/spec/perf/store_perf_spec.rb +88 -11
  134. data/spec/ping/gcm_spec.rb +99 -0
  135. data/spec/server/server_spec.rb +7 -0
  136. data/spec/server/stats_spec.rb +9 -2
  137. data/spec/source_sync_spec.rb +29 -0
  138. data/spec/spec_helper.rb +40 -38
  139. data/spec/stats/record_spec.rb +18 -9
  140. data/spec/store_spec.rb +128 -19
  141. data/spec/testdata/10000-data.txt +0 -0
  142. data/spec/testdata/5-data.txt +0 -0
  143. data/spec/testdata/5000-data.txt +0 -0
  144. data/tasks/jasmine.rake +1 -0
  145. data/tasks/redis.rake +16 -13
  146. metadata +71 -39
  147. data/commands/commands/redis_commands/redis_download.rb +0 -33
  148. data/commands/commands/redis_commands/redis_install.rb +0 -26
  149. data/commands/commands/rhoconnect/attach.rb +0 -8
  150. data/commands/commands/rhoconnect/console.rb +0 -15
  151. data/commands/commands/rhoconnect/start.rb +0 -18
  152. data/commands/utilities/dtach_installed.rb +0 -10
@@ -1,7 +1,7 @@
1
1
  Setting Up for RhoConnect Push on Client Application
2
2
  ===
3
3
 
4
- Push notification support (receiving push notifications from the RhoConnect server/backend) is currently available for Android, Blackberry and iPhone.
4
+ Push notification support (receiving push notifications from the RhoConnect server/backend) is currently available for Android, Blackberry and iPhone.
5
5
 
6
6
  ## Configuring a Rhodes Application to Receive Push
7
7
 
@@ -30,7 +30,7 @@ To handle a push message from a Rhodes application, you must register push callb
30
30
 
31
31
  Push callback is set up in the form of a local application URL and called as callback whether or not rho_callback=1 is specified in its parameters list.
32
32
 
33
- The parameters trigger certain operations in the Rhodes client when the callback returns "rho_push". (When the callback retuens an empty string, this automatic handling is not performed.) The operations are to show an alert, vibrate the device, play a sound, and perform a sync.
33
+ The parameters trigger certain operations in the Rhodes client when the callback returns "rho_push". (When the callback returns an empty string, this automatic handling is not performed.) The operations are to show an alert, vibrate the device, play a sound, and perform a sync.
34
34
 
35
35
  To have your Rhodes app automatically perform the operations listed in the push message, you can write the callback as follows.
36
36
 
@@ -59,3 +59,73 @@ To set up your Rhodes client for push, refer to these links for your respective
59
59
  * [Setting up iPhone Client for Push](/rhodes/device-caps#iphone-push-setup)
60
60
  * [Setting up Android Client for Push](/rhodes/device-caps#android-push-setup)
61
61
  * [Setting up Blackberry Client for Push](/rhodes/device-caps#blackberry-push-setup)
62
+
63
+ ## Configuring a Rhodes Application to Receive Push with RhoConnect Push Service
64
+
65
+ RhoConnect Push Service is a separate process that will run on your machine and broker push messages between your RhoConnect server and registered Android and Windows Mobile/CE devices.
66
+
67
+ NOTE: You do not perform the setup steps in the Rhodes Device Capabilities chapter when you use the RhoConnect Server Push Service. That setup is for regular RhoConnect push, not for the RhoConnect Server Push Service.
68
+
69
+ ### Installing the rhoconnect-push-service Runtime Apps
70
+
71
+ To use the RhoConnect Push Service in your client application, you must install the rhoconnect-push-service runtime app(s) on your mobile device.
72
+
73
+ On the Macintosh, the rhoconnect-push-service runtime apps for Android and for Windows Mobile are located in the Motorola RhoMobile Suite installation package, in a folder called rhoconnect-push-service.
74
+
75
+ On Windows, the rhoconnect-push-service runtime apps for Android and for Windows Mobile are located in the Motorola RhoMobile Suite installation, in a directory called rhoconnect-push-service.
76
+
77
+ If you are using an Android device, install `rhoconnect_push_service.apk` to your device.
78
+
79
+ If you are using a Windows Mobile or CE device, install the following runtime apps on your device.
80
+
81
+ * `rhoconnect-push-service.CAB`
82
+ * `NETCFv35.Messages.EN.wm.cab`
83
+ * `NETCFv35.Messages.EN.cab`
84
+
85
+ ### Configuring rhoconfig.txt
86
+
87
+ In your client application `rhoconfig.txt` file, set the following options to configure your RhoConnect Push Service.
88
+
89
+ syncserver = 'http://<hostname>:<port>/application'
90
+ rhoconnect_push_server = 'http://<hostname>:<port>'
91
+ rhoconnect_push_appname = 'someappname'
92
+
93
+ Next, your RhoConnect application should be running on a network that is accessible to your device. For example, you might have your RhoConnect application running on a LAN with IP 192.168.1.10, PORT 9292. Then make sure your device is connected to the same LAN and set up your application rhoconfig.txt syncserver as follows:
94
+
95
+ Here is an example of setting `rhoconfig.txt` for the RhoConnect Push Service. The URLs used for the RhoConnect Push Service (rhoconnect_push_server) and the RhoConnect server running on the same host.
96
+
97
+ syncserver = 'http://192.168.1.10:9292/application'
98
+ rhoconnect_push_server = 'http://192.168.1.10:8675'
99
+ rhoconnect_push_appname = 'someappname'
100
+
101
+ ### Configuring build.yml
102
+
103
+ When you configure your application `build.yml` file for RhoConnect Server Push Service, you do not add `push` under `capabilities` for RhoConnect Server Push Service. Instead, you add rhoconnect-push to extensions.
104
+
105
+ extensions: ["rhoconnect-push"]
106
+
107
+ You can still enable vibrate in `build.yml` capabilities.
108
+
109
+ capabilities:
110
+ - vibrate #=> if you want to enable vibrate in your push messages
111
+
112
+ ### Registering a Push Callback in your Client Application with RhoConnect Server Push Service
113
+
114
+ To handle a RhoConnect Server Push Service push message from your Rhodes/RhoElements application, you must register callback with the set_push_notification method.
115
+
116
+ To get push messages from RhoConnect server, the user must be logged into the RhoConnect server.
117
+
118
+ In application.rb:
119
+
120
+ :::ruby
121
+ if SyncEngine::logged_in > 0
122
+ System.set_push_notification("/app/Settings/your_rhoconnect_callback",'')
123
+ end
124
+
125
+ [Understanding the Rhodes Push Message Payload](/rhoconnect/push-client-setup#understanding-the-rhodes-push-message-payload) shows the structure of the hash for the callback push message. You can write the push callback to automatically perform some of the operations in the hash by using "rho_push", as shown in [Registering a Push Callback in the Rhodes Application](/rhoconnect/push-client-setup#registering-a-push-callback-in-the-rhodes-application).
126
+
127
+ ### Push Callback, Push Payload
128
+
129
+ Refer to [Rhodes Device Capabilities - Push Notifications - Push Callback](/rhodes/device-caps#push-callback) for more information about setting up a push callback.
130
+
131
+ Refer to [Rhodes Device Capabilities - Push Notifications - Push Payload](/rhodes/device-caps#push-payload) for more information about setting up the push payload.
@@ -8,7 +8,7 @@ To set up your RhoConnect server application for delivering push messages, you n
8
8
  To set up your RhoConnect application for pushing to an iOS client, you will need to update `settings/settings.yml` to include the following:
9
9
 
10
10
  :::yaml
11
- :development:
11
+ :development:
12
12
  :redis: localhost:6379
13
13
  :iphonecertfile: settings/apple_push_cert.pem
14
14
  :iphonepassphrase: #=> empty or put password for your certificate
@@ -27,7 +27,7 @@ This is for running your application in development mode; for production, you wi
27
27
  To set up your RhoConnect application for pushing to a BlackBerry client, you will need to update `settings/settings.yml` to include the following:
28
28
 
29
29
  :::yaml
30
- :development:
30
+ :development:
31
31
  :redis: localhost:6379
32
32
  :mdsserver: 192.168.1.110
33
33
  :mdsserverport: 8080
@@ -36,9 +36,30 @@ To set up your RhoConnect application for pushing to a BlackBerry client, you wi
36
36
 
37
37
  Replace `:mdsserver:` and `:mdsserverport:` with the hostname/IP and port of your machine (default port is 8080).
38
38
 
39
- ## Setting up RhoConnect Server Push for Android
39
+ ## Setting up RhoConnect Server Push for Android (GCM)
40
+
41
+ To set up your RhoConnect application for Android Google Cloud Messaging (GCM), you need to obtain a GCM API key.
40
42
 
41
- To set up your RhoConnect application for Android push, you will need to update `settings/settings.yml` to include the following:
43
+ To do so, set up GCM developer access. Follow the [Getting Started instructions in the GCM documentation](http://developer.android.com/guide/google/gcm/gs.html#create-proj). You can optionally stop in these instructions once you complete the [Obtaining an API Key](http://developer.android.com/guide/google/gcm/gs.html#access-key) section.
44
+
45
+ Your GCM API key will be found in your [Google apis dashboard](https://code.google.com/apis/console).
46
+
47
+ Update `settings/settings.yml` to include your GCM API key:
48
+
49
+ :::yaml
50
+ :development:
51
+ :redis: localhost:6379
52
+ :syncserver: http://localhost:9292/application/
53
+ :licensefile: settings/license.key
54
+ :gcm_api_key: your_gcm_api_key_here
55
+
56
+ Start up your RhoConnect application and setup [push notifications](/rhodes/device-caps#push-notifications) in your Rhodes application.
57
+
58
+ ## Setting up RhoConnect Server Push for Android (C2DM)
59
+
60
+ **NOTE: Google has officially deprecated the C2DM service and requires that you now use Google Cloud Messaging (GCM). Please see [Google's announcement](https://developers.google.com/android/c2dm/) for more details. Follow the instructions at [Setting up RhoConnect Server Push for Android (GCM)](/rhoconnect/push-server-setup#setting-up-rhoconnect-server-push-for-android-gcm) to set up your RhoConnect Application for GCM push.**
61
+
62
+ To set up your RhoConnect application for Android C2DM push, you will need to update `settings/settings.yml` to include the following:
42
63
 
43
64
  :::yaml
44
65
  :development:
@@ -49,7 +70,7 @@ To set up your RhoConnect application for Android push, you will need to update
49
70
  :c2dm_passwd: passwd
50
71
  :authtoken: authtoken
51
72
 
52
- In order to push messages to the Android device, your server needs to obtain Google's C2DM authentication token associated with the trusted google account.
73
+ In order to push messages to an Android device, your server needs to obtain Google's C2DM authentication token associated with the trusted google account.
53
74
  For this purpose, you can specify C2DM Google account's username/password combo via the `:c2dm_username` and `:c2dm_passwd` settings.
54
75
  At run-time, the system will use these credentials to obtain the C2DM token and store it in the Redis for the future use.
55
76
  Once the token is expired, the system will automatically connect to the Google C2DM service to renew the token.
@@ -61,13 +82,113 @@ For those who interested in what this token means, the description is [here](htt
61
82
 
62
83
  Now start up your RhoConnect application and setup [push notifications](/rhodes/device-caps#push-notifications) in your Rhodes application.
63
84
 
85
+ ## Setting up RhoConnect Server Push Service
86
+
87
+ **NOTE: This option is still a _beta_ feature. You may encounter issues using this service.**
88
+
89
+ RhoConnect v3.3 introduces the RhoConnect Push Service (RPS) which supports efficient messaging for both Android and Windows Mobile. This service can be used instead of Google C2DM on Android.
90
+
91
+ The typical flow of a message using RPS:
92
+
93
+ Device RPS RhoConnect Backend App
94
+ + + + +
95
+ | | | |
96
+ | | | POST |
97
+ | | POST |/rc/v1/users/ping|
98
+ | |/instanceId |<----------------+
99
+ | |<-----------+ |
100
+ |<----------+ | |
101
+ |{"content"}| | |
102
+ | | | |
103
+ + + + +
104
+
105
+ ### Download and Install Nodejs
106
+
107
+ If you are using a Macintosh, go to the [Node.js website](http://nodejs.org/#), and download and install Node.js. (Motorola RhoMobile Suite for Windows includes Node.js in its installation.)
108
+
109
+ ### Starting the Push Service
110
+
111
+ RhoConnect Push Service is a separate process that will run on your machine and broker push messages between your RhoConnect server and registered devices.
112
+
113
+ First, create a file called "config.json" with the following content:
114
+
115
+ :::json
116
+ {
117
+ "httpSecure": "n",
118
+ "devAuthHost": "localhost",
119
+ "devAuthUrl": "/rc/v1/app/ans_login",
120
+ "devAuthPort": "9292",
121
+ "userAuthHost": "localhost",
122
+ "userAuthUrl": "/rc/v1/app/ans_login",
123
+ "userAuthPort": "9292",
124
+ "appAuthHost": "localhost",
125
+ "appAuthUrl": "/rc/v1/app/ans_login",
126
+ "appAuthPort": "9292",
127
+ "ansResponseTimeout": "300000",
128
+ "ansServerPort": "8675",
129
+ "registrationTimeout": "2592000",
130
+ "clearDataBase": "n",
131
+ "socketPoolSize": 1,
132
+ "debugLevel": "3"
133
+ }
134
+
135
+ The JSON file has the following parameters.
136
+
137
+ * `httpSecure` - Specify whether the push server will be an https or http server (y/n).
138
+ * `devAuthHost` - RhoConnect instance used to handle device credentials.
139
+ * `devAuthUrl` - Path used on the RhoConnect instance to handle device credentials.
140
+ * `devAuthPort` - Port used on the RhoConnect instance to handle device credentials.
141
+ * `userAuthHost` - RhoConnect instance used to handle user credentials.
142
+ * `userAuthUrl` - Path used on the RhoConnect instance to handle user credentials.
143
+ * `userAuthPort` - Port used on the RhoConnect instance to handle user credentials.
144
+ * `appAuthHost` - RhoConnect instance used to handle application credentials.
145
+ * `appAuthUrl` - Path used on the RhoConnect instance to handle application credentials.
146
+ * `appAuthPort` - Port used on the RhoConnect instance to handle application credentials.
147
+ * `ansResponseTimeout` - Time (in ms) that the push server will allow a message request from the client to go without a response. Upon expiration of this time, a 204 response will be issued and the request will be considered satisfied. If this parameter is set to 0, then this time limit will not be in effect - there is no limit to how long a client request will go without a response.
148
+ * `ansServerPort` - Push server listening port
149
+ * `registrationTimeout` - Expiration limit for registration tokens (in seconds), the client-side application is automatically unregistered if there is no activity related to its token for the registrationTimeout period. Activity related to its token consists of either attempted fetches of messages on its behalf by the push client or messages sent to the push server by RhoConnect.
150
+ * `clearDataBase` - Clear the redis database containing tokens, instanceIds, etc. at the start of the push server (y/n).
151
+ * `socketPoolSize` - The maximum number of sockets the push server will use when connecting to each of the authorization servers. This essentially caps the number of http requests to each authorization server that the push server can have outstanding at any given time.
152
+ * `debugLevel` - Print additional information to console to aid in debugging:
153
+ * 0 - print only error & warning info
154
+ * 1 - print error & warning info and message for each invoked ANS operation
155
+ * 2 - reserved for future use
156
+ * 3 - print everything
157
+
158
+
159
+ Assuming you've installed the latest [RhoMobile Suite](http://www.motorola.com/Business/US-EN/RhoMobile%20Suite/Downloads), start redis.
160
+
161
+ :::term
162
+ $ rhoconnect redis-start
163
+
164
+ Now start RhoConnect Push by running the following in a command line:
165
+
166
+ :::term
167
+ $ rhoconnect-push -c /path/to/your/config.json
168
+
169
+ For example:
170
+
171
+ :::term
172
+ $ rhoconnect-push -c C:/dev/config.json
173
+
174
+ Next, make sure you have the following option in your RhoConnect application's `settings/settings.yml` file in the `:development:`, `:production:` and `:test:` sections:
175
+
176
+ :::yaml
177
+ :push_server: http://someappname@localhost:8675/
178
+
179
+ Where `someappname` is a shared secret between your RhoConnect application and your mobile application.
180
+
181
+ **NOTE: This ensures that only your RhoConnect application can send push messages to the RPS instance you started up in the previous step. Use this in your [mobile app's 'rhoconnect_push_appname' setting](/rhoconnect/push-client-setup#configuring-a-rhodes-application-to-receive-push-with-rhoconnect-push-service). **
182
+
183
+ Now setup [push notifications](/rhoconnect/push-client-setup#configuring-a-rhodes-application-to-receive-push-with-rhoconnect-push-service) in your Android or Windows Mobile RhoElements application, then start up your RhoConnect application.
184
+
64
185
  ## Testing Push in the RhoConnect Web Console
65
186
 
66
- The [RhoConnect Web Console](/rhoconnect/web-console) includes a utility for testing push to make sure everything is wired up correctly.
187
+ The [RhoConnect Web Console](/rhoconnect/web-console) includes a utility for testing push to make sure everything is wired up correctly.
67
188
 
68
- First, make sure you've logged in and performed a sync on the device/simulator you are going to test.
189
+ First, make sure you've logged in and performed a sync on the device/simulator you are going to test.
69
190
 
70
- Next, once you've logged into the web console, navigate to the user's page you used to login in the Rhodes application. For example, if you logged in as user 't', the url would be:
191
+ Next, once you've logged into the web console, navigate to the user's page you used to login in the Rhodes application. For example, if you logged in as user 't', the url would be:
71
192
 
72
193
  http://localhost:9292/console/user?user_id=t
73
194
 
data/doc/rails-plugin.txt CHANGED
@@ -1,4 +1,4 @@
1
- rhoconnect-rb
1
+ rhoconnect-rb [![Build Status](https://secure.travis-ci.org/rhomobile/rhoconnect-rb.png)](http://travis-ci.org/rhomobile/rhoconnect-rb)
2
2
  ===
3
3
 
4
4
  A ruby library for the [RhoConnect](http://rhomobile.com/products/rhoconnect) App Integration Server.
@@ -12,23 +12,23 @@ Load the `rhoconnect-rb` library:
12
12
  require 'rhoconnect-rb'
13
13
 
14
14
  Note, if you are using datamapper, install the `dm-serializer` library and require it in your application. `rhoconnect-rb` depends on this utility to interact with Rhoconnect applications using JSON.
15
-
15
+
16
16
  ## Setup the Model
17
- Now include Rhoconnect::Resource in a model that you want to synchronize with your mobile application:
17
+ Now include Rhoconnectrb::Resource in a model that you want to synchronize with your mobile application:
18
18
 
19
19
  class Product < ActiveRecord::Base
20
- include Rhoconnect::Resource
20
+ include Rhoconnectrb::Resource
21
21
  end
22
-
22
+
23
23
  Or, if you are using DataMapper:
24
24
 
25
25
  class Product
26
26
  include DataMapper::Resource
27
- include Rhoconnect::Resource
27
+ include Rhoconnectrb::Resource
28
28
  end
29
29
 
30
30
  ## Partitioning Datasets
31
-
31
+
32
32
  Next, your models will need to declare a partition key for `rhoconnect-rb`. This partition key is used by `rhoconnect-rb` to uniquely identify the model dataset when it is stored in a rhoconnect instance. It is typically an attribute on the model or related model. `rhoconnect-rb` supports two types of partitions:
33
33
 
34
34
  * :app - No unique key will be used, a shared dataset is synchronized for all users.
@@ -37,21 +37,21 @@ Next, your models will need to declare a partition key for `rhoconnect-rb`. Thi
37
37
  For example, the `Product` model above might have a `belongs_to :user` relationship. This provides us a simple way to organize the `Product` dataset for rhoconnect by reusing this relationship. The partition identifying a username would be declared as:
38
38
 
39
39
  class Product < ActiveRecord::Base
40
- include Rhoconnect::Resource
41
-
40
+ include Rhoconnectrb::Resource
41
+
42
42
  belongs_to :user
43
-
44
- def partition
45
- lambda { self.user.username }
43
+
44
+ def partition
45
+ lambda { self.user.username }
46
46
  end
47
47
  end
48
-
48
+
49
49
  Now all of the `Product` data synchronized by rhoconnect will organized by `self.user.username`. Note: You can also used a fixed key if the dataset doesn't require a dynamic value:
50
50
 
51
51
  def partition
52
52
  :app
53
53
  end
54
-
54
+
55
55
  For more information about Rhoconnect partitions, please refer to the [Rhoconnect docs](http://docs.rhomobile.com/rhoconnect/source-adapters#data-partitioning).
56
56
 
57
57
  ## Querying Datasets
@@ -59,20 +59,20 @@ For more information about Rhoconnect partitions, please refer to the [Rhoconnec
59
59
  `rhoconnect-rb` installs a `/rhoconnect/query` route in your application which the Rhoconnect instance invokes to query the dataset for the dataset you want to synchronize. This route is mapped to a `rhoconnect_query` method in your model. This method should return a collection of objects:
60
60
 
61
61
  class Product < ActiveRecord::Base
62
- include Rhoconnect::Resource
63
-
62
+ include Rhoconnectrb::Resource
63
+
64
64
  belongs_to :user
65
-
66
- def partition
67
- lambda { self.user.username }
65
+
66
+ def partition
67
+ lambda { self.user.username }
68
68
  end
69
-
70
- def self.rhoconnect_query(partition)
71
- Product.includes(:user).where("users.username = ?",partition)
69
+
70
+ def self.rhoconnect_query(partition, attributes = nil)
71
+ Product.includes(:user).where("users.username = ?", partition)
72
72
  end
73
73
  end
74
74
 
75
- In this example, `self.rhoconnect_query` returns a list of products where the partition string (provided by the rhoconnect instance) matches the `user_id` field in the products table.
75
+ In this example, `self.rhoconnect_query` returns a list of products where the partition string (provided by the rhoconnect instance) matches the `user_id` field in the products table.
76
76
 
77
77
  ## Configuration and Authentication
78
78
 
@@ -83,41 +83,246 @@ Configure RhoConnect in an initializer like `config/initializers/rhoconnect.rb`
83
83
  config.uri = "http://myrhoconnect.com"
84
84
  config.token = "secrettoken"
85
85
  config.app_endpoint = "http://myapp.heroku.com"
86
-
86
+
87
87
  If `app_endpoint` is defined, your Rhoconnect instance will be configured to query data from the endpoint using the rhoconnect_query method in your model. For example, if your `app_endpoint` is defined as "http://myapp.heroku.com", RhoConnect will query data with:
88
88
 
89
89
  POST http://myapp.heroku.com/rhoconnect/query
90
90
 
91
- Example:
91
+ Example:
92
92
 
93
- Rhoconnect.configure do |config|
94
- config.uri = "http://myrhoconnect-server.com"
95
- config.token = "secrettoken"
96
- config.app_endpoint = "http://myapp.heroku.com"
93
+ Rhoconnectrb.configure do |config|
94
+ config.uri = "http://localhost:8675"
95
+ config.token = "mydevtoken"
96
+ config.app_endpoint = "http://localhost:3000"
97
97
  end
98
-
98
+
99
99
  Example with authentication:
100
100
 
101
101
  `rhoconnect-rb` installs a `/rhoconnect/authenticate` route into your application which will receive credentials from the client. Add block which handles the credentials:
102
102
 
103
- Rhoconnect.configure do |config|
104
- config.uri = "http://myrhoconnect-server.com"
105
- config.token = "secrettoken"
106
- config.authenticate = lambda { |credentials|
107
- User.authenticate(credentials['login'], credentials['password'])
103
+ Rhoconnectrb.configure do |config|
104
+ config.uri = "http://localhost:8675"
105
+ config.token = "mydevtoken"
106
+ config.app_endpoint = "http://localhost:3000"
107
+ config.authenticate = lambda { |credentials|
108
+ User.authenticate(credentials[:login], credentials[:password])
108
109
  }
109
110
  end
110
-
111
+
111
112
  ### Using the [RhoConnect Heroku Addon](http://docs.rhomobile.com/rhoconnect/heroku-addon)
112
113
 
113
114
  If you're using the [RhoConnect Heroku Addon](http://docs.rhomobile.com/rhoconnect/heroku-addon), then you can omit the config.uri and config.token (they are managed for you):
114
115
 
115
- Rhoconnect.configure do |config|
116
- config.authenticate = lambda { |credentials|
117
- User.authenticate(credentials['login'], credentials['password'])
116
+ Rhoconnectrb.configure do |config|
117
+ config.app_endpoint = "http://myapp.heroku.com"
118
+ config.authenticate = lambda { |credentials|
119
+ User.authenticate(credentials[:login], credentials[:password])
118
120
  }
119
121
  end
120
-
122
+
123
+ ## Rhoconnect-rb API
124
+
125
+ ### Overview of the API
126
+
127
+ The Rhoconnectrb::API module contains routes to all the resources available in <a href='http://docs.rhomobile.com/rhoconnect/rest-api'>Rhoconnect</a>. At a high level the API calls take on the following syntax:
128
+
129
+ Namespace::Resource.verb_action1_action2_...([resource_id,action1_id,action2_id],data)
130
+
131
+ Some of these values are not used for every API call such as resource_id and data.
132
+
133
+ ### System Resource
134
+
135
+ #### `POST /rc/v1/system/login`
136
+
137
+
138
+ data = {:login=>'username',:password=>'password'}
139
+ Rhoconnectrb::API::System.post_login(data)
140
+
141
+ #### `GET /rc/v1/system/license`
142
+
143
+
144
+ Rhoconnectrb::API::System.get_license
145
+
146
+ #### `POST /rc/v1/system/reset`
147
+
148
+
149
+ Rhoconnectrb::API::System.post_reset({})
150
+
151
+ #### `GET /rc/v1/system/appserver`
152
+
153
+
154
+ Rhoconnectrb::API::System.get_appserver
155
+
156
+ #### `POST /rc/v1/system/appserver`
157
+
158
+
159
+ data = {:adapter_url=>'http://test.com'}
160
+ Rhoconnectrb::API::System.post_appserver(data)
161
+
162
+ #### `GET /rc/v1/system/stats`
163
+
164
+
165
+ data ={:names=>"*sources*"}
166
+ Rhoconnectrb::API::System.get_stats(data)
167
+
168
+ ### Store Resource
169
+
170
+ #### `GET /rc/v1/store/:doc`
171
+
172
+
173
+ Rhoconnectrb::API::Store.get('docname')
174
+
175
+ #### `POST /rc/v1/store/:doc`
176
+
177
+
178
+ data = {:data=>{:id=3},:append=>false}
179
+ Rhoconnectrb::API::Store.post('docname',data)
180
+
181
+ ### User Resource
182
+
183
+ #### `POST /rc/v1/users`
184
+
185
+
186
+ data = {:attributes=>{:login=>'login',:password=>'password'}}
187
+ Rhoconnectrb::API::Users.post(data)
188
+
189
+ #### `DELETE /rc/v1/users/:user_id`
190
+
191
+
192
+ Rhoconnectrb::API::Users.delete('user_id')
193
+
194
+ #### `PUT /rc/v1/users/:user_id`
195
+
196
+
197
+ data = {:attributes=>{:a_user_specific_attribute => a_user_specific_attribute_value}}
198
+ Rhoconnectrb::API::Users.put('user_id',data)
199
+
200
+ #### `GET /rc/v1/users`
201
+
202
+
203
+ Rhoconnectrb::API::Users.get
204
+
205
+ #### `Get /rc/v1/users/:user_id`
206
+
207
+ Rhoconnectrb::API::Users.get('user_id')
208
+
209
+ #### `Get /rc/v1/users/:user_id/clients`
210
+
211
+
212
+ Rhoconnectrb::API::Users.get_clients(['user_id','client_id'])
213
+
214
+ #### `DELETE /rc/v1/users/:user_id/clients/:client_id`
215
+
216
+
217
+ Rhoconnectrb::API::Users.delete_clients(['user_id','client_id'])
218
+
219
+ #### `GET /rc/v1/users/:user_id/sources/:source_id/docnames`
220
+
221
+
222
+ Rhoconnectrb::API::Users.get_sources_docnames(['user_id','source_id'])
223
+
224
+ #### `POST /rc/v1/users/ping`
225
+
226
+
227
+ data = {
228
+ :api_token => token,
229
+ :user_id => [array_of_users],
230
+ :sources => source_name,
231
+ :message => 'hello world',
232
+ :vibrate => 2000,
233
+ :sound => 'hello.mp3'
234
+ }
235
+ Rhoconnectrb::API::Users.post_ping(data)
236
+
237
+ #### `GET /rc/v1/users/:user_id/sources/:source_id/docs/:doc`
238
+
239
+
240
+ Rhoconnectrb::API::Users.get_sources_docs(['user_id','source_id','docname'])
241
+
242
+ #### `POST /rc/v1/users/:user_id/sources/:source_id/docs/:doc`
243
+
244
+
245
+ data = {:data=>data,:append=>false}
246
+ Rhoconnectrb::API::Users.post_sources_docs(['user_id','source_id','docname'],data)
247
+
248
+ ### Read State Resource
249
+
250
+ #### `POST /rc/v1/read_state/users/:user_id/sources/:source_id`
251
+
252
+
253
+ data = {:refresh_time => 100}
254
+ Rhconnectrb::API::ReadState.post_users_sources(['user_id','source_id'])
255
+
256
+ ### Source Resource
257
+
258
+ #### `GET /rc/v1/sources/type/:partition_type`
259
+
260
+
261
+ Rhoconnectrb::API::Sources.get_type('parition_type')
262
+
263
+ #### `GET /rc/v1/sources/:source_id`
264
+
265
+
266
+ Rhoconnectrb::API::Sources.get('source_id')
267
+
268
+ #### `PUT /rc/v1/sources/:source_id`
269
+
270
+
271
+ data = {:user_name=>'username',:data=>{:poll_interval=>25}}
272
+ Rhoconnectrb::API::Sources.put('source_id',data)
273
+
274
+ ### Client Resource
275
+
276
+ #### `GET /rc/v1/clients/:client_id`
277
+
278
+
279
+ Rhoconnectrb::API::Clients.get('client_id')
280
+
281
+ #### `GET /rc/v1/clients/:client_id/sources/:source_id/docnames`
282
+
283
+
284
+ Rhoconnectrb::API::Clients.get_sources_docnames(['client_id','source_id'])
285
+
286
+ #### `POST /rc/v1/clients/:client_id/sources/:source_id/docnames`
287
+
288
+
289
+ data = {:data=>data,:append=>false}
290
+ Rhoconnectrb::API::Clients.post_sources_docnames(['client_id','source_id'],data)
291
+
292
+ ### Resource Resource
293
+
294
+ The Resource class is used for API calls to user defined dynamic or source adapters. The resource name is passed in as a parameter.
295
+
296
+ #### `POST /app/v1/:source_name/push_objects`
297
+
298
+
299
+ data = {:user_id=>'user_id',:objects=>data}
300
+ Rhoconnectrb::API::Resource.post_push_objects('source_name',data)
301
+
302
+ #### `POST /app/v1/:source_name/push_deletes`
303
+
304
+
305
+ data = {:user_id => 'user_id',:objects=>'object_ids'}
306
+ Rhoconnectrb::API::Resource.post_push_deletes('source_name',data)
307
+
308
+ #### `POST /app/v1/:source_name/fast_insert`
309
+
310
+
311
+ data = {:user_id=>'user_id',:objects=>data}
312
+ Rhoconnectrb::API::Resource.post_fast_insert('source_name',data)
313
+
314
+ #### `POST /app/v1/:source_name/fast_update`
315
+
316
+
317
+ data = {:user_id=>'user_id',:objects=>data}
318
+ Rhoconnectrb::API::Resource.post_fast_update('source_name',data)
319
+
320
+ #### `POST /app/v1/:source_name/fast_delete`
321
+
322
+
323
+ data = {:user_id=>'user_id',:objects=>data}
324
+ Rhoconnectrb::API::Resource.post_fast_delete('source_name',data)
325
+
121
326
 
122
327
  ## Meta
123
328
  Created and maintained by Lucas Campbell-Rossen, Vladimir Tarasov and Lars Burgess.