anchor.diff:      {stop, Reason, State};
   
   handle_event(#frame{ command = "CONNECT", headers = Headers } = Frame, StateName, State) ->
  -    Session = util:binary_to_hex(uuid:random()),
       Login = proplists:get_value("login", Headers),
       Passcode = proplists:get_value("passcode", Headers),
       case simplemq_server:auth(Login, Passcode) of
           ok ->
               F = #frame{
                   command = "CONNECTED",
  -                headers = [{"session", Session}]
  +                headers = [{"session", ?state.session}]
               },
               ok = send_frame(?state.socket, F),
  -            {next_state, StateName, State#state{ session = Session }};
  +            {next_state, StateName, State};
           _ ->
               gen_fsm:send_all_state_event(self(), {error, auth_failed, Frame}),
               {next_state, StateName, State}
  
positive.code:     {next_state, StateName, State};
  
  handle_event(#frame{ command = "SEND", headers = Headers } = Frame, StateName, State) ->
      {next_state, StateName, State};
  
  handle_event(Event, StateName, State) ->
      ?log([{state_name, StateName}, {handle_event, Event}]),
  
negative.code: %% @doc
  %% gen_fsm callback
  %%
  terminate(_Reason, _StateName, State) ->
      ?log([
              {ip, ?state.ip_address},
              {port, ?state.port},
              {session, ?state.session},
              {frames_in, ?state.frames_in},
              {frames_out, ?state.frames_out},
              stopped
          ]),
      ok.
  
  %% @spec code_change(OldVsn, StateName, State, Extra) -> Result
  