Class: Wamp::Manager::Event::Hello

Inherits:
Base
  • Object
show all
Defined in:
lib/wamp/manager/event/hello.rb

Overview

Hello Message Event

Instance Attribute Summary

Attributes inherited from Base

#session

Instance Method Summary collapse

Methods inherited from Base

#emit_event_name, #error?, #initialize, #transmit

Constructor Details

This class inherits a constructor from Wamp::Manager::Event::Base

Instance Method Details

#add_event_listenerObject



11
12
13
# File 'lib/wamp/manager/event/hello.rb', line 11

def add_event_listener
  session.transmit(payload)
end

#emit_event(hello) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/wamp/manager/event/hello.rb', line 15

def emit_event(hello)
  session.emit(:authenticate, hello) # handle second hello message
  auth_session = Wamp::Router::Session::Base.new(hello)
  message = update_session_id_and_return(auth_session.handle_auth)
  session.transmit(message.payload)

  session.on(:authenticate) do |authenticate|
    welcome_or_error = update_session_id_and_return(auth_session.authenticate(authenticate))
    session.transmit(welcome_or_error.payload)
  end
end

#listen_event_nameObject



32
33
34
# File 'lib/wamp/manager/event/hello.rb', line 32

def listen_event_name
  :join
end

#update_session_id_and_return(message) ⇒ Object



27
28
29
30
# File 'lib/wamp/manager/event/hello.rb', line 27

def update_session_id_and_return(message)
  session.session_id = message.session_id if message.respond_to?(:session_id) # welcome message
  message
end