Class: Vines::Cluster::StreamProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/vines/cluster.rb

Overview

StreamProxy behaves like an EM::Connection so that stanzas may be sent to remote nodes just as they are to locally connected streams. The rest of the system doesn’t know or care that these “streams” send their traffic over redis pubsub channels.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cluster, session) ⇒ StreamProxy

Returns a new instance of StreamProxy.



206
207
208
209
210
211
212
213
214
# File 'lib/vines/cluster.rb', line 206

def initialize(cluster, session)
  @cluster, @user = cluster, UserProxy.new(cluster, session)
  @node, @available, @interested, @presence =
    session.values_at('node', 'available', 'interested', 'presence')

  unless @presence.nil? || @presence.empty?
    @presence = Nokogiri::XML(@presence).root rescue nil
  end
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



204
205
206
# File 'lib/vines/cluster.rb', line 204

def user
  @user
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


216
217
218
# File 'lib/vines/cluster.rb', line 216

def available?
  @available
end

#interested?Boolean

Returns:

  • (Boolean)


220
221
222
# File 'lib/vines/cluster.rb', line 220

def interested?
  @interested
end

#last_broadcast_presenceObject



224
225
226
# File 'lib/vines/cluster.rb', line 224

def last_broadcast_presence
  @presence
end

#write(stanza) ⇒ Object



228
229
230
# File 'lib/vines/cluster.rb', line 228

def write(stanza)
  @cluster.route(stanza, @node)
end