Sha256: 99920addade2451fdb56fecb11e05e035f9a88957ed7839ff78dadc4332859fe

Contents?: true

Size: 941 Bytes

Versions: 37

Compression:

Stored size: 941 Bytes

Contents

class ChatComponent < Roda::Component
  comp_name :chat
  comp_html "../public/chat/index.html"

  def display
    return unless server?

    request.redirect 'login' unless current_user

    dom.find('.my-account .name span').html current_user.full_name

    component(:layout).display do
      dom.find('body').html
    end
  end

  on :server do
    def get_user_list

    end
  end

  on :reconnect do
    puts 'reconnected'
  end

  on :disconnect do
    puts 'disconnected'
  end

  on :connect do
    puts 'connected'
  end

  on :join do |data|
    if client?
      `console.log(#{data});`
      puts 'joined'
    else
      user_details
    end
  end

  on :leave do |data|
    if client?
      `console.log(#{data});`
      puts 'leave'
    else
      user_details
    end
  end

  def user_details
    {
      id: current_user.id,
      first_name: current_user.first_name,
      last_name: current_user.last_name
    }
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
roda-component-0.1.73 test/dummy/components/chat.rb
roda-component-0.1.72 test/dummy/components/chat.rb
roda-component-0.1.71 test/dummy/components/chat.rb
roda-component-0.1.70 test/dummy/components/chat.rb
roda-component-0.1.69 test/dummy/components/chat.rb
roda-component-0.1.68 test/dummy/components/chat.rb
roda-component-0.1.67 test/dummy/components/chat.rb
roda-component-0.1.66 test/dummy/components/chat.rb
roda-component-0.1.65 test/dummy/components/chat.rb
roda-component-0.1.64 test/dummy/components/chat.rb
roda-component-0.1.63 test/dummy/components/chat.rb
roda-component-0.1.62 test/dummy/components/chat.rb
roda-component-0.1.61 test/dummy/components/chat.rb
roda-component-0.1.60 test/dummy/components/chat.rb
roda-component-0.1.59 test/dummy/components/chat.rb
roda-component-0.1.58 test/dummy/components/chat.rb
roda-component-0.1.57 test/dummy/components/chat.rb
roda-component-0.1.56 test/dummy/components/chat.rb
roda-component-0.1.55 test/dummy/components/chat.rb
roda-component-0.1.54 test/dummy/components/chat.rb