<commit_before>#include "App.h"

#include "helpers.h"

/* This function pushes data to the uSockets mock */
extern "C" void us_loop_read_mocked_data(struct us_loop *loop, char *data, unsigned int size);

uWS::TemplatedApp<false> *app;
us_listen_socket_t *listenSocket;

extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {

    /* ws->getUserData returns one of these */
    struct PerSocketData {
        int nothing;
    };

    /* Very simple WebSocket echo server */
    app = new uWS::TemplatedApp<false>(uWS::App().ws<PerSocketData>("/*", {
        /* Settings */
        .compression = uWS::SHARED_COMPRESSOR,
        /* We want this to be low so that we can hit it, yet bigger than 256 */
        .maxPayloadLength = 300,
        .idleTimeout = 10,
        /* Handlers */
        .open = [](auto *ws, auto *req) {
                /* Subscribe to anything */
                ws->subscribe(req->getHeader("topic"));
        },
        .message = [](auto *ws, std::string_view message, uWS::OpCode opCode) {
            if (message.length() && message[0] == 'C') {
                ws->close();
            } else if (message.length() && message[0] == 'E') {
                ws->end(1006);
            } else {
                /* Publish to topic sent by message */
                ws->publish(message, message, opCode, true);

                if (message.length() && message[0] == 'U') {
                   ws->unsubscribe(message);
                }
            }
        },
        .drain = [](auto *ws) {
            /* Check getBufferedAmount here */
        },
        .ping = [](auto *ws) {<commit_msg>Update MockedBroadcastingEchoServer.cpp<commit_after>#include "App.h"

#include "helpers.h"

/* This function pushes data to the uSockets mock */
extern "C" void us_loop_read_mocked_data(struct us_loop *loop, char *data, unsigned int size);

uWS::TemplatedApp<false> *app;
us_listen_socket_t *listenSocket;

extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {

    /* ws->getUserData returns one of these */
    struct PerSocketData {
        int nothing;
    };

    /* Very simple WebSocket echo server */
    app = new uWS::TemplatedApp<false>(uWS::App().ws<PerSocketData>("/*", {
        /* Settings */
        .compression = uWS::SHARED_COMPRESSOR,
        /* We want this to be low so that we can hit it, yet bigger than 256 */
        .maxPayloadLength = 300,
        .idleTimeout = 10,
        /* Handlers */
        .open = [](auto *ws) {
                /* Subscribe to anything */
                ws->subscribe(/*req->getHeader(*/"topic"/*)*/);
        },
        .message = [](auto *ws, std::string_view message, uWS::OpCode opCode) {
            if (message.length() && message[0] == 'C') {
                ws->close();
            } else if (message.length() && message[0] == 'E') {
                ws->end(1006);
            } else {
                /* Publish to topic sent by message */
                ws->publish(message, message, opCode, true);

                if (message.length() && message[0] == 'U') {
                   ws->unsubscribe(message);
                }
            }
        },
        .drain = [](auto *ws) {
            /* Check getBufferedAmount here */
        },
        .ping = [](auto *ws) {
{'fraction_non_alphanumeric': 0.14836341388803917, 'fraction_numerical': 0.009177118384827165, 'mean_word_length': 1.8963684676705048, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1070102', 'n_tokens_mistral': 1030, 'n_tokens_neox': 976, 'n_words': 253}