Sha256: 9e6ff7ea933ffbf81131156cd1776c17e9c2f23f84fe71f4dac49cd63cd01458

Contents?: true

Size: 741 Bytes

Versions: 8

Compression:

Stored size: 741 Bytes

Contents

require 'rubygems'
require 'ramaze'

require __DIR__ 'model/history'
require __DIR__ 'model/message'

class ChatRoom < Ramaze::Controller
  map '/'
  HISTORY = History.new

  [ "Hello, World!",
    "My name is manveru",
    "I welcome you to my realm",
    "The unique and most awesome examples/chat.rb!",
  ].each{|text| HISTORY.write('manveru', text) }

  layout :default

  def index
    return unless request.post?
    session[:nick] = h(request[:nick])
    redirect r(:chat)
  end

  def chat
    redirect r(:/) unless session[:nick]
  end

  def say
    nick, text = session[:nick], request[:text]
    HISTORY.write(nick, h(text)) if nick and text
  end

  def listen
    respond HISTORY.to_html
  end
end

Ramaze.start :mode => :live

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ramaze-2023.01.06 examples/app/chat/start.rb
ramaze-2012.12.08 examples/app/chat/start.rb
ramaze-2012.12.08b examples/app/chat/start.rb
ramaze-2012.04.14 examples/app/chat/start.rb
ramaze-2012.03.07 examples/app/chat/start.rb
ramaze-2011.12.28 examples/app/chat/start.rb
ramaze-2011.10.23 examples/app/chat/start.rb
ramaze-2011.07.25 examples/app/chat/start.rb