-
Notifications
You must be signed in to change notification settings - Fork 1k
Ruby
Marcus S edited this page Dec 23, 2021
·
7 revisions
Type which ruby
into the console. Replace the first line of the app below with that path (don't delete the shebang, though (#!
)
#!/usr/bin/env ruby
# SIMPLE RUBY ECHO SERVER EXAMPLE
def say(msg)
STDOUT.puts msg
STDOUT.flush
end
def input
STDIN.gets.chomp
end
say 'welcome'
command = ''
while command != 'exit'
command = input
say command
end
save it as echo.rb
and make it executable:
$ chmod +x ./echo.rb
./websocketd --port=8080 ./echo.rb
The websocketd user guide is a publicly editable wiki. Please contribute!
Getting Started
Reference
Language specific
Advanced: Internals
Spanish Websocket Wiki
Primeros pasos
Referencia
Lenguajes
Avanzado