Class: UCEngine::Client::Session

Inherits:
Struct
  • Object
show all
Includes:
NetHttpRequest, NetHttpResponse
Defined in:
lib/em-ucengine/client.rb,
lib/em-ucengine/client_nethttp.rb

Overview

Session represent the U.C.Engine client with and sid and uid See #connect

Direct Known Subclasses

EventMachine::UCEngine::Client::Session

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from NetHttpRequest

#delete, #get, #json_post, #post

Methods included from NetHttpResponse

#answer, #answer_bool, #answer_connect

Instance Attribute Details

#sidObject

Returns the value of attribute sid

Returns:

  • (Object)

    the current value of sid



56
57
58
# File 'lib/em-ucengine/client.rb', line 56

def sid
  @sid
end

#uceObject

Returns the value of attribute uce

Returns:

  • (Object)

    the current value of uce



56
57
58
# File 'lib/em-ucengine/client.rb', line 56

def uce
  @uce
end

#uidObject

Returns the value of attribute uid

Returns:

  • (Object)

    the current value of uid



56
57
58
# File 'lib/em-ucengine/client.rb', line 56

def uid
  @uid
end

Instance Method Details

#create_meeting(meeting, body = {}, &block) ⇒ Object

Create a meeting

Parameters:

  • meeting (String)

    name

  • metadata (Hash)


150
151
152
153
# File 'lib/em-ucengine/client.rb', line 150

def create_meeting(meeting, body={}, &block)
  body.merge!(:name => meeting)
  answer post(url("/meeting/"), body), &block
end

#create_role(data, &block) ⇒ Object

Create a role

Parameters:

  • data (Hash)


247
248
249
# File 'lib/em-ucengine/client.rb', line 247

def create_role(data, &block)
  answer post(url("/role/"), data), &block
end

#create_user(data, &block) ⇒ Object

Create user

Parameters:

  • data (Hash)


101
102
103
# File 'lib/em-ucengine/client.rb', line 101

def create_user(data, &block)
  answer post(url("/user"), data), &block
end

#delete_file(meeting, filename, &block) ⇒ Object

Delete a file

Parameters:

  • meeting (String)
  • filename (String)


230
231
232
# File 'lib/em-ucengine/client.rb', line 230

def delete_file(meeting, filename, &block)
  answer delete(url("/file/#{meeting}/#{filename}")), &block
end

#delete_role(name, &block) ⇒ Object

Delete a role

Parameters:

  • name (String)


254
255
256
# File 'lib/em-ucengine/client.rb', line 254

def delete_role(name, &block)
  answer delete(url "/role/#{name}"), &block
end

#delete_user(uid, &block) ⇒ Object

Delete a user

Parameters:

  • uid (String)


116
117
118
# File 'lib/em-ucengine/client.rb', line 116

def delete_user(uid, &block)
  answer delete(url("/user/#{uid}")), &block
end

#disconnect(sid, &block) ⇒ Object

Disconnect a user

Parameters:

  • Sid (String)


80
81
82
# File 'lib/em-ucengine/client.rb', line 80

def disconnect(sid, &block)
  answer delete(url "/presence/#{sid}"), &block
end

#event(id, &block) ⇒ Object

Get event

Parameters:

  • id (String)


212
213
214
215
# File 'lib/em-ucengine/client.rb', line 212

def event(id, &block)
  # Fixme: remove meeting fake param on the 0.7 release
  answer get(url("/event/meeting/#{id}"), {}), &block
end

#events(meeting = nil, params = {}, &block) ⇒ Object

Get events

Parameters:

  • meeting (String) (defaults to: nil)
  • params (Hash) (defaults to: {})


193
194
195
# File 'lib/em-ucengine/client.rb', line 193

def events(meeting=nil, params={}, &block)
  answer get(url("/event/#{meeting}"), params), &block
end

#files(meeting, params = {}, &block) ⇒ Object

List files on a meeting room

Parameters:

  • meeting (String)
  • params (Hash) (defaults to: {})


238
239
240
# File 'lib/em-ucengine/client.rb', line 238

def files(meeting, params={}, &block)
  answer get(url("/file/#{meeting}"), params), &block
end

#join_roster(meeting, body = {}, &block) ⇒ Object

Join the meeting

Parameters:

  • meeting (String)


175
176
177
# File 'lib/em-ucengine/client.rb', line 175

def join_roster(meeting, body={}, &block)
  answer post(url "/meeting/#{meeting}/roster", body), &block
end

#meeting(meeting, &block) ⇒ Object

Get meeting

Parameters:

  • meeting (String)


142
143
144
# File 'lib/em-ucengine/client.rb', line 142

def meeting(meeting, &block)
  answer get(url "/meeting/#{meeting}"), &block
end

#meetings(&block) ⇒ Object

List meetings



135
136
137
# File 'lib/em-ucengine/client.rb', line 135

def meetings(&block)
  answer get(url "/meeting/"), &block
end

#presence(sid, &block) ⇒ Object

Get infos on the presence

Parameters:

  • Sid (String)


73
74
75
# File 'lib/em-ucengine/client.rb', line 73

def presence(sid, &block)
  answer get(url("/presence/#{sid}")), &block
end

#publish(type, meeting = nil, metadata = nil, parent = nil, &block) ⇒ Object

Publish event

Parameters:

  • type (String)
  • meeting (String) (defaults to: nil)
  • metadata (Hash) (defaults to: nil)


202
203
204
205
206
207
# File 'lib/em-ucengine/client.rb', line 202

def publish(type, meeting=nil, =nil, parent=nil, &block)
  args = { :type => type, :uid => uid, :sid => sid }
  args[:parent] = parent if parent
  args[:metadata] =  if 
  answer json_post(url("/event/#{meeting}"), args), &block
end

#quit_roster(meeting, uid = nil, &block) ⇒ Object

Quit the meeting

Parameters:

  • meeting (String)
  • uid (String) (defaults to: nil)


183
184
185
# File 'lib/em-ucengine/client.rb', line 183

def quit_roster(meeting, uid=nil, &block)
  answer delete(url "/meeting/#{meeting}/roster/#{uid || @uid}"), &block
end

#roster(meeting, &block) ⇒ Object

List users on the meeting

Parameters:

  • meeting (String)


168
169
170
# File 'lib/em-ucengine/client.rb', line 168

def roster(meeting, &block)
  answer get(url "/meeting/#{meeting}/roster"), &block
end

#search(params, &block) ⇒ Object

Search

Parameters:

  • params (Hash)


220
221
222
# File 'lib/em-ucengine/client.rb', line 220

def search(params, &block)
  answer get(url "/search/event/", params, &block)
end

#time(&block) ⇒ Object

Get server time



64
65
66
# File 'lib/em-ucengine/client.rb', line 64

def time(&block)
  answer get(url("/time")), &block
end

#update_meeting(meeting, body = {}, &block) ⇒ Object

Update a meeting

Parameters:

  • meeting (String)

    name

  • metadata (Hash)


159
160
161
# File 'lib/em-ucengine/client.rb', line 159

def update_meeting(meeting, body={}, &block)
  answer put(url "/meeting//#{meeting}", body), &block
end

#update_user(uid, data, &block) ⇒ Object

Update user

Parameters:

  • uid (String)
  • data (Hash)


109
110
111
# File 'lib/em-ucengine/client.rb', line 109

def update_user(uid, data, &block)
  answer put(url("/user/#{uid}"), data), &block
end

#url(*args) ⇒ Object



57
58
59
# File 'lib/em-ucengine/client.rb', line 57

def url(*args)
  uce.url(*args)
end

#user(uid, &block) ⇒ Object

Get user info

Parameters:

  • uid (String)


94
95
96
# File 'lib/em-ucengine/client.rb', line 94

def user(uid, &block)
  answer get(url("/user/#{uid}")), &block
end

#user_can(uid, action, object, conditions = {}, location = "", &block) ⇒ Object

Check user ACL

Parameters:

  • uid (String)
  • action (String)
  • object (String)
  • conditions (Hash) (defaults to: {})
  • meeting (String)

    name



127
128
129
# File 'lib/em-ucengine/client.rb', line 127

def user_can(uid, action, object, conditions={}, location="", &block)
  answer_bool get(url("/user/#{uid}/can/#{action}/#{object}/#{location}"), :conditions => conditions), &block
end

#user_role(uid, params = {}, &block) ⇒ Object

Set a role to a user

Parameters:

  • uid (String)
  • params (Hash) (defaults to: {})


262
263
264
# File 'lib/em-ucengine/client.rb', line 262

def user_role(uid, params={}, &block)
  answer post(url("/user/#{uid}/roles"), params), &block
end

#users(&block) ⇒ Object

List users



87
88
89
# File 'lib/em-ucengine/client.rb', line 87

def users(&block)
  answer get(url "/user"), &block
end