anchor.diff:              end
       end.
   
  +last_ws_state([#ws_frame_info{ws_state=State}|Rest], _LastState) ->
  +    last_ws_state(Rest, State);
  +last_ws_state([], LastState) ->
  +    LastState;
  +last_ws_state([{frame_incomplete, _}], LastState) ->
  +    LastState.
   
   handle_callback(Type, [#state{cbinfo=CbInfo}=State | Args]) ->
       Cb = case Type of
  
positive.code:         Other ->
              Other
      end;
  
  ws_frame_info(WSState = #ws_state{sock=Socket}, FirstPacket, Opts) ->
      ws_frame_info(WSState, buffer(Socket, 2, FirstPacket), Opts).
  
  
  ws_frame_info_secondary(Socket, Masked, Len1, Rest, Opts) ->
      MaxLen = get_opts(max_frame_size, Opts),
      CloseIfUnmasked = get_opts(close_if_unmasked, Opts),
      MaskLength = case Masked of
                       0 -> 0;
                       1 -> 4
                   end,
      case Len1 of
          126 ->
              <<Len:16, MaskingKey:MaskLength/binary, Rest2/binary>> =
                  buffer(Socket, MaskLength + 2 , Rest);
          127 ->
              <<Len:64, MaskingKey:MaskLength/binary, Rest2/binary>> =
                  buffer(Socket, MaskLength + 8 , Rest);
          Len ->
              <<MaskingKey:MaskLength/binary, Rest2/binary>> =
                  buffer(Socket, MaskLength, Rest)
      end,
      if
          CloseIfUnmasked == true andalso MaskingKey == <<>> ->
              error_logger:error_msg("Unmasked frame forbidden", []),
              {fail_connection, ?WS_STATUS_PROTO_ERROR,
               <<"Unmasked frame forbidden">>};
          Len > MaxLen ->
              error_logger:error_msg(
                "Payload length ~p longer than max allowed of ~p",
                [Len, MaxLen]
               ),
              {fail_connection, ?WS_STATUS_MSG_TOO_BIG, <<"Frame too big">>};
          true ->
              <<Payload:Len/binary, Excess/binary>> = buffer(Socket, Len, Rest2),
              {ws_frame_info_secondary, Len, MaskingKey, Payload, Excess}
      end.
  
  unframe_active_once(WSState, FirstPacket, Opts) ->
      Frames = unframe(WSState, FirstPacket, Opts),
      websocket_setopts(WSState, [{active, once}]),
      Frames.
  
  
  %% Returns all the WebSocket frames fully or partially contained in FirstPacket,
  %% reading exactly as many more bytes from Socket as are needed to finish
  
negative.code:                                  vsn       = WSVersion,
                                   frag_type = none},
              handshake(CliSock, WSKey, Protocol),
              websocket_setopts(WSState, [{active, true}]),
  
              case CbInfo#cbinfo.open_fun of
                  undefined ->
  