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:     fragmented_message = undefined :: #message{}
    }).
  
  %%========================================
  %% Types
  %%========================================
  -type encoding() :: text | binary.
  -type client_name() :: {local, atom()} | {global, atom()} | anon.
  
  %%========================================
  %% Constants
  %%========================================
  -define(CLOSE_HANDSHAKE_TIMEOUT, 2000).
  -define(TCP_CLOSE_TIMEOUT, 500).
  -define(DEFAULT_REG_NAME, ?MODULE).
  