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
kinetic_sdk-5.0.2.beta.2 gems/websocket-driver-0.6.5/examples/tcp_server.rb
kinetic_sdk-5.0.2.beta.2 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb
kinetic_sdk-5.0.2.beta.1 gems/websocket-driver-0.6.5/examples/tcp_server.rb
kinetic_sdk-5.0.2.beta.1 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb
kinetic_sdk-5.0.1 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb
kinetic_sdk-5.0.1 gems/websocket-driver-0.6.5/examples/tcp_server.rb
kinetic_sdk-5.0.0 gems/websocket-driver-0.6.5/examples/tcp_server.rb
kinetic_sdk-5.0.0 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb
kinetic_sdk-1.0.2 gems/websocket-driver-0.6.5/examples/tcp_server.rb
kinetic_sdk-1.0.2 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb
kinetic_sdk-1.0.1 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb
kinetic_sdk-1.0.1 gems/websocket-driver-0.6.5/examples/tcp_server.rb
kinetic_sdk-1.0.0 gems/websocket-driver-0.6.5/examples/tcp_server.rb
kinetic_sdk-1.0.0 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb
kinetic_sdk-0.1.1 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb
kinetic_sdk-0.1.1 gems/websocket-driver-0.6.5/examples/tcp_server.rb
websocket-driver-kontena-0.6.5 examples/tcp_server.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/websocket-driver-0.6.5/examples/tcp_server.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/websocket-driver-0.6.5/examples/tcp_server.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/websocket-driver-0.6.5/examples/tcp_server.rb