Class: Shove::Http::ClientContext

Inherits:
Object
  • Object
show all
Defined in:
lib/shove/http/client_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, id) ⇒ ClientContext

Returns a new instance of ClientContext.



7
8
9
10
# File 'lib/shove/http/client_context.rb', line 7

def initialize app, id
  @app = app
  @id = id
end

Instance Attribute Details

#appObject

Returns the value of attribute app.



5
6
7
# File 'lib/shove/http/client_context.rb', line 5

def app
  @app
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/shove/http/client_context.rb', line 5

def id
  @id
end

Instance Method Details

#deny_connect(&block) ⇒ Object

grant connection to client use this to kick a client block called on response



39
40
41
# File 'lib/shove/http/client_context.rb', line 39

def deny_connect &block
  @app.request("deny_connect?client=#{@id}").post(&block)
end

#deny_control(&block) ⇒ Object

grant connection to client use this to revoke power. Clients will never have control by default, so this would always be called after calling grant_control block called on response



48
49
50
# File 'lib/shove/http/client_context.rb', line 48

def deny_control &block
  @app.request("deny_control?client=#{@id}").post(&block)
end

#deny_publish(channel, &block) ⇒ Object

deny publishing to client channel the channel to deny publishing on block called on response



76
77
78
# File 'lib/shove/http/client_context.rb', line 76

def deny_publish channel, &block
  @app.request("deny_publish?channel=#{channel}&client=#{@id}").post(&block)
end

#deny_subscribe(channel, &block) ⇒ Object

deny subscription to client channel the channel to deny subscription on block called on response



69
70
71
# File 'lib/shove/http/client_context.rb', line 69

def deny_subscribe channel, &block
  @app.request("deny_subscribe?channel=#{channel}&client=#{@id}").post(&block)
end

#grant_connect(&block) ⇒ Object

grant connection to client use this in cases where the app disallows any activity on newly established clients. block called on response



23
24
25
# File 'lib/shove/http/client_context.rb', line 23

def grant_connect &block
  @app.request("grant_connect?client=#{@id}").post(&block)
end

#grant_control(&block) ⇒ Object

grant control to client turns the client into a full blown control client, allowing them to subscribe and publish to all channels, as well as grant and deny actions to other clients block called on response



32
33
34
# File 'lib/shove/http/client_context.rb', line 32

def grant_control &block
  @app.request("grant_control?client=#{@id}").post(&block)
end

#grant_publish(channel, &block) ⇒ Object

grant publishing to client channel the channel to grant publishing on block called on response



62
63
64
# File 'lib/shove/http/client_context.rb', line 62

def grant_publish channel, &block
  @app.request("grant_publish?channel=#{channel}&client=#{@id}").post(&block)
end

#grant_subscribe(channel, &block) ⇒ Object

grant subscription to client channel the channel to grant subscription on block called on response



55
56
57
# File 'lib/shove/http/client_context.rb', line 55

def grant_subscribe channel, &block
  @app.request("grant_subscribe?channel=#{channel}&client=#{@id}").post(&block)
end

#publish(message, &block) ⇒ Object

publish a message directly to the client message the message to publish block called on response



15
16
17
# File 'lib/shove/http/client_context.rb', line 15

def publish message, &block
  @app.request("publish?channel=direct:#{@id}").post(message.to_s, &block)
end