Sha256: 631483f4395dc8fe245e9633458373af5f601c23dc5bb23dc93b6c85603ff7af

Contents?: true

Size: 1.35 KB

Versions: 8

Compression:

Stored size: 1.35 KB

Contents

shared_examples_for "a WebSocket server drafts 3 and above" do
  it "should force close connections after a timeout if close handshake is not sent by the client" do
    em {
      server_onerror_fired = false
      server_onclose_fired = false
      client_got_close_handshake = false
      
      start_server(:close_timeout => 0.1) { |ws|
        ws.onopen {
          # 1: Send close handshake to client
          EM.next_tick { ws.close(4999, "Close message") }
        }
        
        ws.onerror { |e|
          # 3: Client should receive onerror
          e.class.should == EM::WebSocket::WSProtocolError
          e.message.should == "Close handshake un-acked after 0.1s, closing tcp connection"
          server_onerror_fired = true
        }
        
        ws.onclose {
          server_onclose_fired = true
        }
      }
      start_client { |client|
        client.onmessage { |msg|
          # 2: Client does not respond to close handshake (the fake client 
          # doesn't understand them at all hence this is in onmessage)
          msg.should =~ /Close message/ if version >= 6
          client_got_close_handshake = true
        }
        
        client.onclose {
          server_onerror_fired.should == true
          server_onclose_fired.should == true
          client_got_close_handshake.should == true
          done
        }
      }
    }
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
em-websocket-0.5.3 spec/integration/gte_03_examples.rb
em-websocket-0.5.2 spec/integration/gte_03_examples.rb
sonixlabs-em-websocket-0.5.1.5 spec/integration/gte_03_examples.rb
sonixlabs-em-websocket-0.5.1.4 spec/integration/gte_03_examples.rb
sonixlabs-em-websocket-0.5.1.3 spec/integration/gte_03_examples.rb
sonixlabs-em-websocket-0.5.1.2 spec/integration/gte_03_examples.rb
sonixlabs-em-websocket-0.5.1.1 spec/integration/gte_03_examples.rb
em-websocket-0.5.1 spec/integration/gte_03_examples.rb