Sha256: 961632f6bc7d4d7fae71f4e05472bb3a028b0949f3e89d9bc72515e6a0901198

Contents?: true

Size: 520 Bytes

Versions: 2

Compression:

Stored size: 520 Bytes

Contents

require 'rubygems'
require 'lib/em-http'

module KBHandler
  include EM::Protocols::LineText2

  def receive_line(data)
    p "Want to send: #{data}"
    p "Error status: #{$http.error?}"
    $http.send(data)
    p "After send"
  end
end

EventMachine.run {
  $http = EventMachine::HttpRequest.new("ws://localhost:8080/").get :timeout => 0

  $http.disconnect { puts 'oops' }
  $http.callback {
    puts "WebSocket connected!"
  }

  $http.stream { |msg|
    puts "Recieved: #{msg}"
  }

  EM.open_keyboard(KBHandler)
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
em-http-request-0.2.10 examples/websocket-handler.rb
em-http-request-0.2.9 examples/websocket-handler.rb