Sha256: 68ab170341bd44a3015f074206968e62d95a4c88916491a729b32d219ee5b08d

Contents?: true

Size: 1.27 KB

Versions: 7

Compression:

Stored size: 1.27 KB

Contents

# encoding: UTF-8

shared_examples_for "a websocket client" do
  it "should accept a single-frame binary message" do
    EM.run do
      start_server { |server|
        server.onmessage { |msg, type|
          msg.should == '\xFF\xFF'
          type.should == :binary
          EM.stop
        }
        server.onerror {
          failed
        }
      }

      options = { :host => '0.0.0.0', :port => 12345, :debug => false }
      client = EM.connect('0.0.0.0', 12345, EventMachine::WebSocket::ClientConnection, options) do |ws|
        ws.onopen do
          ws.send '\xFF\xFF', :binary
        end
      end
    end
  end

  it "should accept a text message in the same frame as the server handshake response" do
    EM.run do
      start_server { |server|
        server.onopen { server.send 'hello' }
        server.onerror { failed }
      }
      
      options = { :host => '0.0.0.0', :port => 12345, :debug => false }
      client = EM.connect( options[:host], options[:port], EventMachine::WebSocket::ClientConnection, options) do |ws|
        ws.onmessage{ |msg, type| 
          msg.should == 'hello'
          type.should == :text
          EM.stop
        }
        
        EventMachine::add_timer 3 do
          failed # ran out of time
        end
      end
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sonixlabs-em-websocket-0.5.1.5 spec/integration/client_examples.rb
sonixlabs-em-websocket-0.5.1.4 spec/integration/client_examples.rb
sonixlabs-em-websocket-0.5.1.3 spec/integration/client_examples.rb
sonixlabs-em-websocket-0.5.1.2 spec/integration/client_examples.rb
sonixlabs-em-websocket-0.5.1.1 spec/integration/client_examples.rb
sonixlabs-em-websocket-0.3.8 spec/integration/client_examples.rb
sonixlabs-em-websocket-0.3.7 spec/integration/client_examples.rb