anchor.diff:  %% @hidden
   -spec handle_info({tcp, Socket::gen_tcp:socket(), Data::binary()}, connecting, #data{}) -> {next_state, atom(), #data{}}.
   handle_info({tcp, Socket, Data}, connecting, StateData) ->
  -  Response = wsecli_http:from_response(Data),
  -  case wsecli_handshake:validate(Response, StateData#data.handshake) of
  -    true ->
  +  {ok, Response} = wsock_http:decode(Data, response),
  +  case wsock_handshake:handle_response(Response, StateData#data.handshake) of
  +    {ok, _Handshake} ->
         spawn(StateData#data.cb#callbacks.on_open),
         {next_state, open, StateData};
  -    false ->
  +    {error, _Error} ->
         {stop, failed_handshake, StateData}
     end;
   
   handle_info({tcp, Socket, Data}, open, StateData) ->
     {Messages, State} = case StateData#data.fragmented_message of
       undefined ->
  -      {wsecli_message:decode(Data), StateData};
  +      {wsock_message:decode(Data, []), StateData};
       Message ->
  -      {wsecli_message:decode(Data, Message), StateData#data{fragmented_message = undefined}}
  +      {wsock_message:decode(Data, Message, []), StateData#data{fragmented_message = undefined}}
     end,
     NewStateData = process_messages(Messages, State),
     {next_state, open, NewStateData};
   
   handle_info({tcp, Socket, Data}, closing, StateData) ->
  -  [Message] = wsecli_message:decode(Data),
  +  [Message] = wsock_message:decode(Data, []),
     case Message#message.type of
       close ->
         % if we don't receive a tcp_closed message, move to closed state anyway
  
positive.code:   {next_state, open, StateData};
  
  open({send, Data}, StateData) ->
    Message = wsecli_message:encode(Data, text),
    case gen_tcp:send(StateData#data.socket, Message) of
      ok ->
        ok;
  
negative.code: init({Host, Port, Resource}) ->
    {ok, Socket} = gen_tcp:connect(Host, Port, [binary, {reuseaddr, true}, {packet, raw}] ),
  
    Handshake = wsock_handshake:open(Resource, Host, Port),
    Request = wsock_http:encode(Handshake#handshake.message),
  
    ok = gen_tcp:send(Socket, Request),
    {ok, connecting, #data{ socket = Socket, handshake = Handshake}}.
  