Sha256: 52ff249dbd755b6d70afff3080ee1920daebbf235d54d1d72f8101d2dda88c7a

Contents?: true

Size: 449 Bytes

Versions: 129

Compression:

Stored size: 449 Bytes

Contents

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

class EchoServer < EM::Connection
  def receive_data(data)
    if data.strip =~ /exit$/i
      EventMachine.stop
    else
      send_data(data)
    end
  end
end

EventMachine.run do
  # hit Control + C to stop
  Signal.trap("INT")  { EventMachine.stop }
  Signal.trap("TERM") { EventMachine.stop }

  EventMachine.start_server("0.0.0.0", 10000, EchoServer)
end

Version data entries

129 entries across 126 versions & 10 rubygems

Version Path
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/2.6.0/gems/eventmachine-1.2.7/examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/3.1.0/gems/eventmachine-1.2.7/examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/3.0.0/gems/eventmachine-1.2.7/examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
eventmachine-mkroman-1.3.0.dev.1 examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
wj_eventmachine-1.3.2 examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
wj_eventmachine-1.3.1 examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
wj_eventmachine-1.3.0.dev.1 examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
sensu-em-2.7.0-java examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
eventmachine-1.2.7-java examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
eventmachine-1.2.7-x64-mingw32 examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
eventmachine-1.2.7-x86-mingw32 examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
eventmachine-1.2.7 examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
eventmachine-1.2.6-x64-mingw32 examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
eventmachine-1.2.6-x86-mingw32 examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
eventmachine-1.2.6-java examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
eventmachine-1.2.6 examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
eventmachine-1.2.5-x86-mingw32 examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
eventmachine-1.2.5-x64-mingw32 examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
eventmachine-1.2.5-java examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
eventmachine-1.2.5 examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb