Sha256: 8e5325b43929f87467726c5a57bc99871c607227b2a8136ad17f409cfe73b5af

Contents?: true

Size: 854 Bytes

Versions: 3

Compression:

Stored size: 854 Bytes

Contents

# Allow examples to be run directly outside of the Gem
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
require 'rubygems'
require 'ruby_skynet'

# Log trace information to a log file
SemanticLogger::Logger.default_level = :trace
SemanticLogger::Logger.appenders << SemanticLogger::Appender::File.new('echo_server.log')

# Specify Port and Hostname to listen for requests on
RubySkynet::Server.port = 2020
RubySkynet::Server.hostname = '127.0.0.1'

# Just echo back any parameters received when the echo method is called
class EchoService
  include RubySkynet::Service

  # Methods implemented by this service
  # Must take a Hash as input
  # Must Return a Hash response or nil for no response
  def echo(params)
    params
  end
end

# Start the server
RubySkynet::Server.start

puts "Press enter to shutdown server"
gets

RubySkynet::Server.stop

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_skynet-0.5.0 examples/echo_server.rb
ruby_skynet-0.4.0 examples/echo_server.rb
ruby_skynet-0.4.0.pre2 examples/echo_server.rb