ucengine 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/ucengine.rb +14 -14
- data/ucengine.gemspec +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/lib/ucengine.rb
CHANGED
@@ -20,7 +20,7 @@ require 'uri'
|
|
20
20
|
# uce = UCEngine.new("localhost", 4567)
|
21
21
|
# uce.connect("uce@example.com", :password => 'pwd') do |uce|
|
22
22
|
# uce.subscribe([], :type => 'chat.message.new', :search => 'HTML5') do |event|
|
23
|
-
# uce.publish(:location =>
|
23
|
+
# uce.publish(:location => event['location']
|
24
24
|
# :from => 'bot',
|
25
25
|
# :type => 'chat.message.new',
|
26
26
|
# :metadata => {"text" => "Hey, you were talking about HTML5"})
|
@@ -115,8 +115,8 @@ class UCEngine
|
|
115
115
|
|
116
116
|
# Subscribe to an event stream. The 'location' parameter is where you're expecting
|
117
117
|
# the events to come:
|
118
|
-
# *
|
119
|
-
# *
|
118
|
+
# * "meeting": events from a specific meeting.
|
119
|
+
# * "": all events.
|
120
120
|
#
|
121
121
|
# The function takes extra parameters:
|
122
122
|
# :type => the type of event (ex. 'chat.message.new', 'internal.user.add', etc).
|
@@ -136,7 +136,7 @@ class UCEngine
|
|
136
136
|
params[:start] = 0 if !params[:start]
|
137
137
|
while true
|
138
138
|
begin
|
139
|
-
events = get("/event/#{location
|
139
|
+
events = get("/event/#{location}", params, http)['result']
|
140
140
|
rescue RestClient::RequestTimeout
|
141
141
|
debug(UCEngine::WARNING, "Subscribe timeout ... retry")
|
142
142
|
retry
|
@@ -162,12 +162,12 @@ class UCEngine
|
|
162
162
|
end
|
163
163
|
|
164
164
|
# Publish an event. Publishing an event require a few mandatories parameters:
|
165
|
-
# [:location] As described in the subscribe method:
|
165
|
+
# [:location] As described in the subscribe method: "meeting" publish the event in a specific meeting or "": publish the event in the server root.
|
166
166
|
# [:type] The type of event to send, the format of this type is usually 'namespace.object.action', for example: 'chat.message.new', 'twitter.tweet.new', 'internal.user.update'
|
167
167
|
# [:parent] The id of the parent, this parameter is useful to build event hierarchy.
|
168
168
|
# [:metadata] A hash of freely defined values to append to the event.
|
169
169
|
#
|
170
|
-
# uce.publish(:location =>
|
170
|
+
# uce.publish(:location => "WebWorkersCamp",
|
171
171
|
# :type => 'presentation.slide.add'
|
172
172
|
# :metadata => {:url => 'http://myserver/slides/03.png',
|
173
173
|
# :index => 3})
|
@@ -181,7 +181,7 @@ class UCEngine
|
|
181
181
|
params["metadata[#{key}]"] = event[:metadata][key]
|
182
182
|
end
|
183
183
|
end
|
184
|
-
post("/event/#{event[:location]
|
184
|
+
post("/event/#{event[:location]}", params)
|
185
185
|
end
|
186
186
|
|
187
187
|
# Return the current timestamp from the server. The timestamp is expressed in milliseconds
|
@@ -196,17 +196,17 @@ class UCEngine
|
|
196
196
|
return time
|
197
197
|
end
|
198
198
|
|
199
|
-
# Download a file from UCEngine. The
|
199
|
+
# Download a file from UCEngine. The location parameter is
|
200
200
|
# where the file sits. The 'id' parameters is the file idenfication number
|
201
201
|
#
|
202
|
-
# uce.download(
|
202
|
+
# uce.download("demo_meeting", "file_43243243253253.pdf")
|
203
203
|
#
|
204
|
-
def download(
|
204
|
+
def download(location, id)
|
205
205
|
Net::HTTP.start(@host, @port) do |http|
|
206
206
|
params = Hash.new
|
207
207
|
params[:uid] = @uid if @uid
|
208
208
|
params[:sid] = @sid if @sid
|
209
|
-
url = URI.escape("http://#{@host}:#{@port}#{API_ROOT}/#{API_VERSION}/file/#{
|
209
|
+
url = URI.escape("http://#{@host}:#{@port}#{API_ROOT}/#{API_VERSION}/file/#{location}/#{id}")
|
210
210
|
|
211
211
|
debug(UCEngine::DEBUG, "Download: #{url}")
|
212
212
|
result = RestClient.get(url, {:params => params})
|
@@ -215,15 +215,15 @@ class UCEngine
|
|
215
215
|
end
|
216
216
|
end
|
217
217
|
|
218
|
-
# Upload a file to UCEngine. The
|
218
|
+
# Upload a file to UCEngine. The location is where
|
219
219
|
# you want the file to be uploaded. The 'file' parameter is a File object.
|
220
220
|
# This function returns a JSON structure {'result': file_id} where 'file_id' is the identification
|
221
221
|
# number of the file.
|
222
222
|
#
|
223
223
|
# uce.upload(["demo_meeting"], File.new("/path/file_to_upload.pdf"))
|
224
224
|
#
|
225
|
-
def upload(
|
226
|
-
url = "http://#{@host}:#{@port}#{API_ROOT}/#{API_VERSION}/file/#{
|
225
|
+
def upload(location, file)
|
226
|
+
url = "http://#{@host}:#{@port}#{API_ROOT}/#{API_VERSION}/file/#{location}?uid=#{@uid}&sid=#{@sid}"
|
227
227
|
debug(UCEngine::DEBUG, "Upload: #{file.path} to #{url}")
|
228
228
|
result = JSON.parse(RestClient.post(url, {:upload => file}))
|
229
229
|
debug(UCEngine::DEBUG, "Upload complete")
|
data/ucengine.gemspec
CHANGED
metadata
CHANGED