Sha256: 408b6ddd4aa533bfab31499b056e4151c5f6c70b7e508ec8294be7a1b22a0fd4

Contents?: true

Size: 757 Bytes

Versions: 5

Compression:

Stored size: 757 Bytes

Contents

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

  # Websockets
  def on_message(data)
    data = ERB::Util.html_escape data
    print data
    broadcast :print, data
  end

  def on_open
    print 'Welcome to appname!'
    @handle = params['id'.freeze] || 'Somebody'
    broadcast :print, "#{ERB::Util.html_escape @handle} joind us :-)"
  end

  def on_close
    broadcast :print, "#{@handle} left us :-("
  end

  protected

  # write is inherites when a Websocket connection is opened.
  #
  # Inherited functions aren't exposed (for our security), so we need to wrap it.
  def print(data)
    write data
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
plezi-0.14.4 resources/ctrlr.rb
plezi-0.14.3 resources/ctrlr.rb
plezi-0.14.2 resources/ctrlr.rb
plezi-0.14.1 resources/ctrlr.rb
plezi-0.14.0 resources/ctrlr.rb