Skip to content
rickcarlino edited this page Nov 13, 2014 · 7 revisions

Step 1: Where's Ruby?

Type which ruby into the console. Replace the first line of the app below with that path (don't delete the shebang, though (#!)

#!/Users/me/.rvm/rubies/ruby-2.1.2/bin/ruby
# SIMPLE RUBY ECHO SERVER EXAMPLE
def say(msg)
  STDOUT.puts msg
  STDOUT.flush
end

def input
  STDIN.gets.chomp
end

say 'welcome'
command = input
while command != 'exit'
  say inp
end

save it as echo.rb

Step 2: Run it!

./websocketd --port=8080 ./echo.rb

Clone this wiki locally