             return i
      return -1
 
-test_protocol = (protocol) ->
+test_protocol_messages = (protocol) ->
     module(protocol)
     if not SockJS[protocol] or not SockJS[protocol].enabled(client_opts.sockjs_opts)
         test "[unsupported by client]", ->


        asyncTest("user close", factor_user_close(protocol))
        asyncTest("server close", factor_server_close(protocol))
        asyncTest("invalid url 404", test_invalid_url_404(protocol))
        asyncTest("invalid url 500", test_invalid_url_500(protocol))
        asyncTest("invalid url port", test_invalid_url_port(protocol))


protocols = ['websocket',
        'xhr-streaming',
        'iframe-eventsource',
        'iframe-htmlfile',
        'xhr-polling',
        'iframe-xhr-polling',
        'jsonp-polling']
for protocol in protocols
    test_protocol(protocol)


module('other')

protocols = ['websocket',
        'xhr-streaming',
        'iframe-eventsource',
        'iframe-htmlfile',
        'xhr-polling',
        'iframe-xhr-polling',
        'jsonp-polling']

newSockJS = (path, protocol) ->
    url = if /^http/.test(path) then path else client_opts.url + path
    return new SockJS(url, [protocol], client_opts.sockjs_opts)
