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.19 gems/websocket-driver-0.6.5/examples/tcp_server.rb
kinetic_sdk-5.0.19 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb
kinetic_sdk-5.0.18 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb
kinetic_sdk-5.0.18 gems/websocket-driver-0.6.5/examples/tcp_server.rb
kinetic_sdk-5.0.17 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb
kinetic_sdk-5.0.17 gems/websocket-driver-0.6.5/examples/tcp_server.rb
kinetic_sdk-5.0.16 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb
kinetic_sdk-5.0.16 gems/websocket-driver-0.6.5/examples/tcp_server.rb
kinetic_sdk-5.0.15 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb
kinetic_sdk-5.0.15 gems/websocket-driver-0.6.5/examples/tcp_server.rb
kinetic_sdk-5.0.14 gems/websocket-driver-0.6.5/examples/tcp_server.rb
kinetic_sdk-5.0.14 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb
kinetic_sdk-5.0.13 gems/websocket-driver-0.6.5/examples/tcp_server.rb
kinetic_sdk-5.0.13 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb
kinetic_sdk-5.0.12 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb
kinetic_sdk-5.0.12 gems/websocket-driver-0.6.5/examples/tcp_server.rb
kinetic_sdk-5.0.11 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb
kinetic_sdk-5.0.11 gems/websocket-driver-0.6.5/examples/tcp_server.rb
kinetic_sdk-5.0.10 gems/websocket-driver-0.6.5/examples/tcp_server.rb
kinetic_sdk-5.0.10 gems/websocket-driver-0.6.5-java/examples/tcp_server.rb