Sha256: 006fd6769a914c78d7d36508a05ba5328b764e471f362e68111c2c82f9d49499

Contents?: true

Size: 634 Bytes

Versions: 91

Compression:

Stored size: 634 Bytes

Contents

require 'rubygems'
require 'bundler/setup'
require 'eventmachine'
require 'websocket/driver'
require 'permessage_deflate'

module Connection
  def initialize
    @driver = WebSocket::Driver.server(self)
    @driver.add_extension(PermessageDeflate)

    @driver.on(:connect) { |e| @driver.start if WebSocket::Driver.websocket? @driver.env }
    @driver.on(:message) { |e| @driver.frame(e.data) }
    @driver.on(:close)   { |e| close_connection_after_writing }
  end

  def receive_data(data)
    @driver.parse(data)
  end

  def write(data)
    send_data(data)
  end
end

EM.run {
  EM.start_server('127.0.0.1', ARGV[0], Connection)
}

Version data entries

91 entries across 63 versions & 7 rubygems

Version Path
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/websocket-driver-0.6.5/examples/tcp_server.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/websocket-driver-0.6.5/examples/tcp_server.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/websocket-driver-0.6.5/examples/tcp_server.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/websocket-driver-0.6.5/examples/tcp_server.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/websocket-driver-0.6.5/examples/tcp_server.rb
websocket-driver-0.6.5-java examples/tcp_server.rb
websocket-driver-0.6.5 examples/tcp_server.rb
abaci-0.3.0 vendor/bundle/gems/websocket-driver-0.6.4/examples/tcp_server.rb
websocket-driver-0.6.4-java examples/tcp_server.rb
websocket-driver-0.6.4 examples/tcp_server.rb
websocket-driver-0.6.3-java examples/tcp_server.rb
websocket-driver-0.6.3 examples/tcp_server.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/websocket-driver-0.5.4/examples/tcp_server.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/websocket-driver-0.5.4/examples/tcp_server.rb
websocket-driver-0.6.2-java examples/tcp_server.rb
websocket-driver-0.6.2 examples/tcp_server.rb
websocket-driver-0.6.1-java examples/tcp_server.rb
websocket-driver-0.6.1 examples/tcp_server.rb
websocket-driver-0.6.0-java examples/tcp_server.rb
websocket-driver-0.6.0 examples/tcp_server.rb