<commit_before>/*
 * Copyright 2017 deepstreamHub GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef DEEPSTREAM_WEBSOCKETS_HPP
#define DEEPSTREAM_WEBSOCKETS_HPP

#include <memory>
#include <string>
#include <utility>

#include <deepstream/core/buffer.hpp>
#include "time.hpp"

namespace deepstream {

namespace websockets {
    /**
     * This structure stores a WebSockets frame.
     *
     * To have the WebSocket data match the values in these enums, the
     * first eight bits of a frame must be interpreted in MSB order (most
     * significant bit first, also known as network order). This agrees
     * with the behavior of the POCO C++ WebSockets libraries.
     *
     * Enum classes are inappropriate here because a valid WebSocket frame
     * always contains combinations of flags.
     */
    struct Frame {
        typedef int Flags;

        struct Bit {
            enum { FIN = 1u << 7,
                RSV1 = 1u << 6,
                RSV2 = 1u << 5,
                RSV3 = 1u << 4 };
        };

        struct Opcode {
            enum {
                CONTINUATION_FRAME = 0,
                TEXT_FRAME = 1,
                BINARY_FRAME = 2,
                CONNECTION_CLOSE_FRAME = 8,
                // pings are implemented in deepstream as `C|PI+` messages
                PING_FRAME = 9,
                // pongs are implemented in deepstream as `C|PO+` messages
                PONG_FRAME = 10
            };
        };

        explicit Frame(Flags, const char*, std::size_t);

        Flags flags() const { return flags_; }

        const Buffer& payload() const { return payload_; }

        Flags flags_;
        Buffer payload_;
    };

    enum class StatusCode {
        UNKNOWN,
        NONE,
        NORMAL_CLOSE = 1000,
        ABNORMAL_CLOSE = 1006
    };

    enum class State { ERROR,
        OPEN,
        CLOSED };

    struct Client {
        virtual ~Client() = default;
<commit_msg>src/core/websockets.hpp: remove dead code<commit_after>/*
 * Copyright 2017 deepstreamHub GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef DEEPSTREAM_WEBSOCKETS_HPP
#define DEEPSTREAM_WEBSOCKETS_HPP

#include <memory>
#include <string>
#include <utility>

#include "time.hpp"
#include <deepstream/core/buffer.hpp>

namespace deepstream {

namespace websockets {
    /**
     * This structure stores a WebSockets frame.
     *
     * To have the WebSocket data match the values in these enums, the
     * first eight bits of a frame must be interpreted in MSB order (most
     * significant bit first, also known as network order). This agrees
     * with the behavior of the POCO C++ WebSockets libraries.
     *
     * Enum classes are inappropriate here because a valid WebSocket frame
     * always contains combinations of flags.
     */
    struct Frame {
        typedef int Flags;

        struct Bit {
            enum { FIN = 1u << 7,
                RSV1 = 1u << 6,
                RSV2 = 1u << 5,
                RSV3 = 1u << 4 };
        };

        struct Opcode {
            enum {
                CONTINUATION_FRAME = 0,
                TEXT_FRAME = 1,
                BINARY_FRAME = 2,
                CONNECTION_CLOSE_FRAME = 8,
                // pings are implemented in deepstream as `C|PI+` messages
                PING_FRAME = 9,
                // pongs are implemented in deepstream as `C|PO+` messages
                PONG_FRAME = 10
            };
        };

        explicit Frame(Flags, const char*, std::size_t);

        Flags flags() const { return flags_; }

        const Buffer& payload() const { return payload_; }

        Flags flags_;
        Buffer payload_;
    };

    enum class State { ERROR,
        OPEN,
        CLOSED };

    struct Client {
        virtual ~Client() = default;

{'fraction_non_alphanumeric': 0.07612312811980033, 'fraction_numerical': 0.012479201331114808, 'mean_word_length': 2.06892150606254, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4518416', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1261, 'n_words': 508}