Sha256: 2bb99df98c1b3e2b4852784548415151d60c4510472e05610a8396fbdbeadedd

Contents?: true

Size: 616 Bytes

Versions: 2

Compression:

Stored size: 616 Bytes

Contents

# Replace this sample with real code.
class ExampleCtrl
  # HTTP
  def index
    # any String returned will be appended to the response. We return a String.
    render 'welcome'
  end

  # Websockets
  def on_open
    subscribe channel: "chat"
    write 'Welcome to appname!'
    @handle = params['id'.freeze] || 'Somebody'
    publish channel: "chat", message: "#{ERB::Util.html_escape @handle} joind us :-)"
  end
  def on_message(data)
    data = ERB::Util.html_escape data
    publish channel: "chat", message: data
  end

  def on_close
    publish channel: "chat", message: "#{@handle} left us :-("
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
plezi-0.15.1 resources/ctrlr.rb
plezi-0.15.0 resources/ctrlr.rb