Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use a single, flat, 'location' parameter instead of a [org, meeting] …

…array
  • Loading branch information...
commit c145f8834addb5747e6bfee748bc3b8fed2141c2 1 parent 2cd70c3
Victor Goya authored
Showing with 14 additions and 14 deletions.
  1. +14 −14 lib/ucengine.rb
View
28 lib/ucengine.rb
@@ -20,7 +20,7 @@
# uce = UCEngine.new("localhost", 4567)
# uce.connect("uce@example.com", :password => 'pwd') do |uce|
# uce.subscribe([], :type => 'chat.message.new', :search => 'HTML5') do |event|
-# uce.publish(:location => [event['meeting']]
+# uce.publish(:location => event['location']
# :from => 'bot',
# :type => 'chat.message.new',
# :metadata => {"text" => "Hey, you were talking about HTML5"})
@@ -115,8 +115,8 @@ def connect(uid, params)
# Subscribe to an event stream. The 'location' parameter is where you're expecting
# the events to come:
- # * ["meeting"]: events from a specific meeting.
- # * []: all events.
+ # * "meeting": events from a specific meeting.
+ # * "": all events.
#
# The function takes extra parameters:
# :type => the type of event (ex. 'chat.message.new', 'internal.user.add', etc).
@@ -136,7 +136,7 @@ def subscribe(location, params = {})
params[:start] = 0 if !params[:start]
while true
begin
- events = get("/event/#{location.join("/")}", params, http)['result']
+ events = get("/event/#{location}", params, http)['result']
rescue RestClient::RequestTimeout
debug(UCEngine::WARNING, "Subscribe timeout ... retry")
retry
@@ -162,12 +162,12 @@ def subscribe(location, params = {})
end
# Publish an event. Publishing an event require a few mandatories parameters:
- # [:location] As described in the subscribe method: ["meeting"] publish the event in a specific meeting or []: publish the event in the server root.
+ # [:location] As described in the subscribe method: "meeting" publish the event in a specific meeting or "": publish the event in the server root.
# [: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'
# [:parent] The id of the parent, this parameter is useful to build event hierarchy.
# [:metadata] A hash of freely defined values to append to the event.
#
- # uce.publish(:location => ["WebWorkersCamp"],
+ # uce.publish(:location => "WebWorkersCamp",
# :type => 'presentation.slide.add'
# :metadata => {:url => 'http://myserver/slides/03.png',
# :index => 3})
@@ -181,7 +181,7 @@ def publish(event)
params["metadata[#{key}]"] = event[:metadata][key]
end
end
- post("/event/#{event[:location].join("/")}", params)
+ post("/event/#{event[:location]}", params)
end
# Return the current timestamp from the server. The timestamp is expressed in milliseconds
@@ -196,17 +196,17 @@ def time
return time
end
- # Download a file from UCEngine. The meeting parameter is
+ # Download a file from UCEngine. The location parameter is
# where the file sits. The 'id' parameters is the file idenfication number
#
- # uce.download(["demo_meeting"], "file_43243243253253.pdf")
+ # uce.download("demo_meeting", "file_43243243253253.pdf")
#
- def download(meeting, id)
+ def download(location, id)
Net::HTTP.start(@host, @port) do |http|
params = Hash.new
params[:uid] = @uid if @uid
params[:sid] = @sid if @sid
- url = URI.escape("http://#{@host}:#{@port}#{API_ROOT}/#{API_VERSION}/file/#{meeting}/#{id}")
+ url = URI.escape("http://#{@host}:#{@port}#{API_ROOT}/#{API_VERSION}/file/#{location}/#{id}")
debug(UCEngine::DEBUG, "Download: #{url}")
result = RestClient.get(url, {:params => params})
@@ -215,15 +215,15 @@ def download(meeting, id)
end
end
- # Upload a file to UCEngine. The meeting is where
+ # Upload a file to UCEngine. The location is where
# you want the file to be uploaded. The 'file' parameter is a File object.
# This function returns a JSON structure {'result': file_id} where 'file_id' is the identification
# number of the file.
#
# uce.upload(["demo_meeting"], File.new("/path/file_to_upload.pdf"))
#
- def upload(meeting, file)
- url = "http://#{@host}:#{@port}#{API_ROOT}/#{API_VERSION}/file/#{meeting}?uid=#{@uid}&sid=#{@sid}"
+ def upload(location, file)
+ url = "http://#{@host}:#{@port}#{API_ROOT}/#{API_VERSION}/file/#{location}?uid=#{@uid}&sid=#{@sid}"
debug(UCEngine::DEBUG, "Upload: #{file.path} to #{url}")
result = JSON.parse(RestClient.post(url, {:upload => file}))
debug(UCEngine::DEBUG, "Upload complete")
Please sign in to comment.
Something went wrong with that request. Please try again.