anchor.diff:               end,
       cowboy_req:reply(200, text_headers(), Packet, Req).
   
  -safe_ubsub_caller(Pid, Caller) ->
  +safe_unsub_caller(undefined, _Caller) ->
  +    ok;
  +
  +safe_unsub_caller(_Pid, undefined) ->
  +    ok;
  +
  +safe_unsub_caller(Pid, Caller) ->
       try
           socketio_session:unsub_caller(Pid, Caller),
           ok
  
positive.code:     ok;
  
  terminate(_Req, _HttpState = #http_state{heartbeat_tref = HeartbeatTRef, pid = Pid}) ->
      safe_ubsub_caller(Pid, self()),
      case HeartbeatTRef of
          undefined ->
              ok;
  
negative.code:         [<<"websocket">>, _Sid] ->
              {upgrade, protocol, cowboy_websocket};
          _ ->
              {ok, Req, #http_state{config = Config}}
      end.
  
  %% Http handlers
  