anchor.diff:  %% @hidden
   handle_cast(stop, State) ->
       {stop, normal, State};
  -handle_cast(Frame = #stomp_frame{}, State) ->
  -    case handle_frame(Frame, State) of
  -        {ok, NewState}           -> {noreply, NewState};
  -        {error, Error, NewState} -> {stop, Error, NewState}
  +handle_cast(Frame = #stomp_frame{command = Cmd}, State) ->
  +    case Cmd of
  +        "STOMP"      -> connect(Frame, State);
  +        "CONNECT"    -> connect(Frame, State);
  +        "DISCONNECT" -> disconnect(Frame, State);
  +        _Unknown     -> unsupported(Frame, State)
       end;
   handle_cast(Msg, State) ->
       {stop, {unhandled_cast, Msg}, State}.
  
positive.code: code_change(_OldVsn, State, _Extra) -> {ok, State}.
  
  %%
  %% Private
  %%
  
  -spec handle_frame(#stomp_frame{}, #s{}) -> {ok | stop, #s{}}.
  %% @private
  handle_frame(Frame = #stomp_frame{command = Cmd}, State) ->
      case Cmd of
          "STOMP"   -> connect(Frame, State);
          "CONNECT" -> connect(Frame, State);
          Unknown   -> send_error(unknown_command,
                                  "Command '~p' is not recognized.~n",
                                  [Unknown],
                                  State)
      end.
  
  %% @private
  connect(#stomp_frame{}, State = #s{session = undefined}) ->
  
negative.code:                [Cmd, Session],
                 State).
  
  %% @disconnect
  disconnect(_Frame, State) -> {stop, normal, State}.
  
  %% @private
  unsupported(#stomp_frame{command = Cmd}, State) ->
      send_error(unsupported_command,
                 "Command '~p' not supported.~n",
                 [Cmd],
                 State).
  
  %%
  %% Socket Communication
  %%
  
  %% @private
  send_error(Message, Format, Args, State) ->
      send_error(Message, lists:flatten(io_lib:format(Format, Args)), State).
  