How to use event-e3 - 2 common examples

To help you get started, we’ve selected a few event-e3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GrosSacASac / JavaScript-Set-Up / js / network / onewaydata / source / onewaydata.js View on Github external
const createEventStream = (options) => {
    const { path, server, asMiddleWare } = options;
    const eventStream = Emitter({ lastEventId: 0 });

    let responses = [];
    let onRequest;

    const requestHandler = (request, response) => {
        if (!isValidRequestForServerSentEvents(request)) {
            return false;
        }

        const { socket } = request;
        socket.setTimeout(0);
        socket.setKeepAlive(true);
        socket.setNoDelay(true);

        response.writeHead(200, {
            [`Content-Type`]: MIME
github GrosSacASac / JavaScript-Set-Up / js / network / socketiyo / source / socketiyo.js View on Github external
httpServer,
        ws,
        path,
        highClients,
        maxClients,
        maxLength,
        maxChannels,
        maxChannelLength,
        lowEnough,
        packData = defaultPackData,
        unpackData = defaultUnpackData,
    } = options;

    const wss = new ws.Server({ server: httpServer, path });

    const facade = EventEmitter({});
    const connectionsPool = new Set();

    facade.connectionsPool = connectionsPool;

    const formatSend = (data, channel) => {
        const toSend = { channel, data };
        return packData(toSend);
    };
    facade.send = (socket, data, channel = DEFAULT_CHANNEL) => {
        if (isSocketInChannel(socket, channel)) {
            socket.send(formatSend(data, channel));
            socket[LAST_CONNECTION_CHECK] = Date.now();
        }
    };

event-e3

Universal light Event Emitter

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis

Popular event-e3 functions