Sha256: 0cbc3433c5574c0314c596c1302833b8388ecda959aa16005d66ffb949c8ed8e

Contents?: true

Size: 552 Bytes

Versions: 10

Compression:

Stored size: 552 Bytes

Contents

module EchoServer
  def self.start
    WebSocket::EventMachine::Server.start(:host => "0.0.0.0", :port => self.port) do |ws|
      @channel = EM::Channel.new
      ws.onopen do
        sid = @channel.subscribe do |mes|
          ws.send mes  # echo to client
        end
        ws.onmessage do |msg|
          @channel.push msg
        end
        ws.onclose do
          @channel.unsubscribe sid
        end
      end
    end
  end

  def self.port
    (ENV['WS_PORT'] || 18080).to_i
  end

  def self.url
    "ws://localhost:#{self.port}"
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
websocket-client-simple-0.9.0 test/echo_server.rb
websocket-client-simple-0.8.0 test/echo_server.rb
websocket-client-simple-0.7.0 test/echo_server.rb
websocket-client-simple-0.6.1 test/echo_server.rb
websocket-client-simple-0.6.0 test/echo_server.rb
websocket-client-simple-0.5.1 test/echo_server.rb
websocket-client-simple-0.5.0 test/echo_server.rb
websocket-client-simple-0.4.0 test/echo_server.rb
websocket-client-simple-0.3.1 test/echo_server.rb
websocket-client-simple-0.3.0 test/echo_server.rb