Class: Kibosh::XMPP::Session

Inherits:
Session
  • Object
show all
Defined in:
lib/kibosh/xmpp/session.rb,
lib/kibosh/xmpp/session/stream.rb

Defined Under Namespace

Modules: CreateSessionRequest Classes: Stream

Instance Attribute Summary

Attributes inherited from Session

#content, #sid

Instance Method Summary collapse

Methods inherited from Session

#accept, #charsets, #defer, find, #hold, #inactivity, #maxpause, #polling, #requests, #respond, #stop, #streams, #ver, #wait

Constructor Details

#initialize(request, response) ⇒ Session

Returns a new instance of Session.



14
15
16
17
18
19
# File 'lib/kibosh/xmpp/session.rb', line 14

def initialize request, response
  client[:version] = Version.new(request["version"]) if request["version"]
  super do |response|
    yield response
  end
end

Instance Method Details

#handle(request, response) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/kibosh/xmpp/session.rb', line 25

def handle request, response
  restart = (attr = request.body.attribute_with_ns("restart",'urn:xmpp:xbosh')) && attr.value == "true"
  if restart
    to = request.body["to"]
    request.body.remove_attribute "to"
    stream = streams[request]
    request.body["to"] = to if to
    stream.restart request, response
  else
    super
  end
end

#versionObject



21
22
23
# File 'lib/kibosh/xmpp/session.rb', line 21

def version
  @version ||= client[:version]
end