anchor.diff:    spawn(Callback),
     {next_state, open, StateData};
   
  -open({send, Data}, StateData) ->
  -  Message = wsock_message:encode(Data, [mask, text]),
  +open({send, Data, Type}, StateData) ->
  +  Message = wsock_message:encode(Data, [mask, Type]),
     case gen_tcp:send(StateData#data.socket, Message) of
       ok ->
         ok;
  
positive.code: %
  %%%%%%%%%%%%%%%%%%%%%
  
  %% @doc This function will start the websocket client
  %%
  %% This function will open a connection with the specified remote endpoint. Parameters
  %% <ul>
  %% <li>Host, a string. The URL of the remote endpoint</li>
  %% <li>Port, an integer. The port where the remote endpoint is listening</li>
  %% <li>Resouce, an string. The resource path where the websockets live</li>
  %% </ul>
  -spec start(Host::string(), Port::integer(), Resource::string()) -> pid().
  start(Host, Port, Path) ->
      start(Host, Port, Path, {local, ?DEFAULT_REG_NAME}).
  
  %% @doc This function will start the websocket client
  %%
  %% This function will open a connection with the specified remote endpoint. Parameters
  %% <ul>
  %% <li>Host, a string. The URL of the remote endpoint</li>
  %% <li>Port, an integer. The port where the remote endpoint is listening</li>
  %% <li>Resouce, an string. The resource path where the websockets live</li>
  %% <li>FsmName, a tuple or 'anon'. 'anon' will skip registering process. See also <a href="http://www.erlang.org/doc/man/gen_fsm.html#start_link-3">here</a></li>
  %% </ul>
  -spec start(Host::string(), Port::integer(), Resource::string(), FsmName::tuple()|atom()) -> pid().
  start(Host, Port, Path, anon) ->
    gen_fsm:start_link(?MODULE, {Host, Port, Path}, [{timeout, 5000}]);
  start(Host, Port, Path, FsmName) ->
  
negative.code: 
  %% @doc Send data to a remote endpoint
  %%
  %% This is the same as calling {@link send/2} with the atom `wsecli' (see {@link start/3}) as first parameter
  %%
  -spec send(
      Data::string()
    ) -> ok;
    (
      Data::binary()
    ) -> ok.
  send(Data) ->
    send(?DEFAULT_REG_NAME, Data).
  
  %% @doc Send data to a remote endpoint
  %%
  %% This is the same as calling {@link send/3} whit the third parameter being the type of the Data sent.
  %%
  -spec send(
    Socket :: pid() | atom(),
    Data :: binary()|string()
    ) -> ok.
  send(Socket, Data) when is_binary(Data) ->
    send(Socket, Data, binary);
  send(Socket, Data) when is_list(Data) ->
    send(Socket, Data, text).
  
  %% @doc Send data to a remote endpoint
  %%
  %% Sends data using the specified wsecli client, encoding the data as the give type.
  %%
  -spec send(
    Socket :: pid() | atom(),
    Data :: binary() | string(),
    Type :: encoding()
    ) -> ok.
  send(Socket, Data, Type) ->
    gen_fsm:send_event(Socket, {send, Data, Type}).
  
  %% @doc Add a callback to be called when a connection is opened
  %%
  