Class: Shove::Http::ChannelContext

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, channel) ⇒ ChannelContext

Returns a new instance of ChannelContext.



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

def initialize app, channel
  @app = app
  @channel = channel
end

Instance Attribute Details

#appObject

Returns the value of attribute app.



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

def app
  @app
end

#channelObject

Returns the value of attribute channel.



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

def channel
  @channel
end

Instance Method Details

#deny_publish(client, &block) ⇒ Object

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



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

def deny_publish client, &block
  control_request("deny_publish", client, &block)
end

#deny_subscribe(client, &block) ⇒ Object

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



41
42
43
# File 'lib/shove/http/channel_context.rb', line 41

def deny_subscribe client, &block
  control_request("deny_subscribe", client, &block)
end

#grant_publish(client, &block) ⇒ Object

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



34
35
36
# File 'lib/shove/http/channel_context.rb', line 34

def grant_publish client, &block
  control_request("grant_publish", client, &block)
end

#grant_subscribe(client, &block) ⇒ Object

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



27
28
29
# File 'lib/shove/http/channel_context.rb', line 27

def grant_subscribe client, &block
  control_request("grant_subscribe", client, &block)
end

#publish(message, &block) ⇒ Object

publish a message on the channel message the message to publish block called on response



15
16
17
18
19
20
21
22
# File 'lib/shove/http/channel_context.rb', line 15

def publish message, &block
  if @channel == "*"
    raise ShoveException.new("Cannot publish to *")
  elsif message.size > 2048
    raise ShoveException.new("Max message size is 2 KiB")
  end
  @app.request("publish?channel=#{@channel}").post(message, &block)
end