Sha256: 4226ab1dd37b3ca2be36a437c0b8634786e89ab57deb3c00b0e11a304b4e62f4

Contents?: true

Size: 548 Bytes

Versions: 6

Compression:

Stored size: 548 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

6 entries across 6 versions & 1 rubygems

Version Path
em-http-request-0.3.0 examples/websocket-handler.rb
em-http-request-0.2.15 examples/websocket-handler.rb
em-http-request-0.2.14 examples/websocket-handler.rb
em-http-request-0.2.13 examples/websocket-handler.rb
em-http-request-0.2.12 examples/websocket-handler.rb
em-http-request-0.2.11 examples/websocket-handler.rb