Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
EventMachine WebSocket client
Ruby
Branch: master

README.md

EventMachine Websocket Client

Gem Version Build Status

This gem implements a WebSocket client inside EventMachine building on top of em-http-request and web-socket-ruby. Supports all the features of em-http-request including SSL, and timeout reconnect.

Installation:

gem install em-websocket-request

Usage:

require 'em-websocket-request'

request = EventMachine::WebsocketRequest.new(
  'wss://ws-1.fury.io',
  :inactivity_timeout => 30
).get

request.errback { |*args|
  puts "[websocket] problem connecting (will retry)"
  request.close
}

request.callback {
  puts "[websocket] Successfully connected"
  http.send("Hello there!")
}

request.disconnect {
  puts "[websocket] disconnected"
}

request.stream { |chunk, type|
  response = process_data(chunk, type)
  http.send(response)
}
Something went wrong with that request. Please try again.