Sha256: ad1fd289bbccc93f5877567365ee9b584423d48788e3729eea9a5ac74ac9c11d

Contents?: true

Size: 951 Bytes

Versions: 1

Compression:

Stored size: 951 Bytes

Contents

require 'hara/base'

Celluloid.logger = nil

def wait_until wait_time = 3
  timeout wait_time do
    sleep 0.1 until yield
  end
end

class FayeHandshake
  def headers_downcased
    {'host' => 'localhost:8080'}
  end
end

class FayeSocket
  attr_accessor :remote_ip, :close_info, :app

  def initialize
    @client_messages = []
    @server_messages = []
    @mri_peername = "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
    @jruby_peername = "\x00\x02\x8Av\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
  end

  def app= app
    @app = app
    @alive = true
  end

  def get_peername
    defined?(JRuby) ? @jruby_peername : @mri_peername
  end

  def alive?
    @alive
  end

  def close code = nil, body = nil
    if @alive
      @close_info = [code, body]
      @alive = false
      @app.terminate!
    end
  end

  def send message
    @client_messages << message
  end

  def client_read
    @client_messages.shift
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hara-0.2.2 spec/spec_helper.rb