anchor.diff:  	?debugMsg("bing"),
   	{next_state, active_once, State}.
   
  +%% @private
   passive({recv, Timeout}, _From, #state{frame_buffer = Frames} = State) when length(Frames) > 0 ->
   	[Frame | Tail] = Frames,
   	if
  
positive.code: 	Reply = Trans:send(Socket, Data),
  	{reply, Reply, Statename, State};
  
  handle_sync_event(Event, _From, Statename, State) ->
  	?debugFmt("handling sync event ~p in state ~p", [Event, Statename]),
  	{reply, {error, nyi}, Statename, State}.
  
  handle_info({TData, Socket, Data}, recv_handshake, {#state{transport_data = TData, socket = Socket} = State, Timeout, From, Before}) ->
  	Buffered = State#state.data_buffer,
  	Buffer = <<Buffered/binary, Data/binary>>,
  
negative.code: 			Else
  	end.
  
  %% @doc Send a message as text. @see send/3.
  -spec send(Socket :: websocket(), Msg :: binary()) -> 'ok'.
  send(Socket, Msg) ->
  	send(Socket, Msg, text).
  
  %% @doc Send a message as the given type.
  -spec send(Socket :: websocket(), Msg :: binary(), Type :: message_type()) -> 'ok'.
  send(Socket, Msg, Type) ->
  	gen_fsm:sync_send_all_state_event(Socket, {send, Type, Msg}).
  
  %% @doc recv/2 with an infinte timeout. @see recv/2
  -spec recv(Socket :: websocket()) -> {'ok', frame()}.
  recv(Socket) ->
  	recv(Socket, infinity).
  
  %% @doc Get a single frame from the socket, giving up after the timeout.
  -spec recv(Socket :: websocket(), Timeout :: timeout()) -> {'ok', frame()} | {'error', 'timeout'}.
  recv(Socket, Timeout) ->
  	gen_fsm:sync_send_event(Socket, {recv, Timeout}).
  
  %% @doc set the controlling process to a new owner. Can only suceede if
  %% called from the current owner.
  -spec controlling_process(Socket :: websocket(), NewOwner :: pid()) -> 'ok' | {'error', 'not_owner'}.
  controlling_process(_Socket, _NewOwner) ->
  	?debugMsg("controlling_process"),
  	{error, nyi}.
  
  %% @doc Close the socket without exiting the process created on socket
  %% connect.
  -spec close(Socket :: websocket()) -> 'ok'.
  close(_Socket) ->
  	?debugMsg("close"),
  	{error, nyi}.
  
  %% @doc Close the socket and shut it down with the given reason.
  -spec shutdown(Socket :: websocket(), How :: term()) -> 'ok'.
  shutdown(_Socket, _How) ->
  	?debugMsg("shutdown"),
  	{error, nyi}.
  
  %% @doc Set the given options on the given socket.
  -spec setopts(Socket :: websocket(), Opts :: connect_opts()) -> 'ok'.
  setopts(Socket, Opts) ->
  	gen_fsm:sync_send_all_state_event(Socket, {setopts, Opts}).
  
  %% @private
  %% gen_fsm api
  init([Controller, Url, _Opts, Timeout]) ->
  	?debugMsg("gen_fsm init"),
  