anchor.diff:      end.
   
   %% Http handlers
  -handle(Req, HttpState = #http_state{action = create_session, version = Version, config = #config{
  +handle(Req, HttpState = #http_state{action = create_session, version = Version, jsonp = JsonP, config = #config{
       heartbeat = HeartbeatInterval,
       heartbeat_timeout = HeartbeatTimeout,
       session_timeout = SessionTimeout,
  
positive.code:         [<<"1">>] ->
              {ok, Req2, #http_state{action = create_session, config = Config, version = 0}};
          [<<"1">>, <<"xhr-polling">>, Sid] ->
              handle_polling(Req2, Sid, Config, 0);
          [<<"1">>, <<"websocket">>, _Sid] ->
              {upgrade, protocol, cowboy_websocket};
          _ ->
              {Sid, _} = cowboy_req:qs_val(<<"sid">>, Req2),
              {Transport, _} = cowboy_req:qs_val(<<"transport">>, Req2),
  
              case {Transport, Sid} of
                  {<<"polling">>, undefined} ->
                      {ok, Req2, #http_state{action = create_session, config = Config, version = 1}};
                  {<<"polling">>, _} when is_binary(Sid) ->
                      handle_polling(Req2, Sid, Config, 1);
                  {<<"websocket">>, _} ->
                      {upgrade, protocol, cowboy_websocket};
                  _ ->
  
negative.code:             error
      end.
  
  safe_poll(Req, HttpState = #http_state{config = Config = #config{protocol = Protocol}, version = Version, jsonp = JsonP}, Pid, WaitIfEmpty) ->
      try
          Messages = socketio_session:poll(Pid),
          case {WaitIfEmpty, Messages} of
              {true, []} when Version =:= 1 ->
                  case socketio_session:transport(Pid) of
                      websocket ->
                          {ok, Req1} = reply_messages(Req, [], Config, true, Version, JsonP),
                          {ok, Req1, HttpState};
                      _ ->
                          {loop, Req, HttpState, hibernate}
  