How to use the uws.native function in uws

To help you get started, we’ve selected a few uws 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 primus / primus / transformers / uws / server.js View on Github external
'use strict';

const http = require('http');
const url = require('url');
const uws = require('uws');

const native = uws.native;

//
// uws v0.12.0+ needs a set "no operation" callback.
//
if (native.setNoop) native.setNoop(() => {});

/**
 * Server of µWebSockets transformer.
 *
 * @runat server
 * @api private
 */
module.exports = function server() {
  const opts = Object.assign({
    perMessageDeflate: !!this.primus.options.compression,
    maxPayload: this.primus.options.maxLength
github deepstreamIO / deepstream.io / dist / src / message / uws / connection-endpoint.js View on Github external
_uwsInit() {
        const maxMessageSize = this._getOption('maxMessageSize');
        const perMessageDeflate = this._getOption('perMessageDeflate');
        this.serverGroup = uws.native.server.group.create(perMessageDeflate, maxMessageSize);
        this.noDelay = this._getOption('noDelay');
        uws.native.server.group.onDisconnection(this.serverGroup, (external, code, message, socketWrapper) => {
            if (socketWrapper) {
                socketWrapper.close();
            }
        });
        uws.native.server.group.onMessage(this.serverGroup, (message, socketWrapper) => {
            const parseResults = socketWrapper.parseMessage(message);
            const parsedMessages = this._handleParseErrors(socketWrapper, parseResults);
            if (parsedMessages.length > 0) {
                socketWrapper.onMessage(parsedMessages);
            }
        });
        uws.native.server.group.onPing(this.serverGroup, () => { });
        uws.native.server.group.onPong(this.serverGroup, () => { });
        uws.native.server.group.onConnection(this.serverGroup, this._onConnection.bind(this));
        this.pingInterval = setInterval(() => {
            uws.native.server.group.broadcast(this.serverGroup, this.pingMessage, true);
github deepstreamIO / deepstream.io / dist / src / message / uws / connection-endpoint.js View on Github external
close() {
        clearInterval(this.pingInterval);
        this.server.removeAllListeners('request');
        this.server.removeAllListeners('upgrade');
        if (this.serverGroup) {
            uws.native.server.group.close(this.serverGroup);
        }
        this.serverGroup = null;
        this.server.close(() => {
            this.emit('close');
        });
    }
}
github deepstreamIO / deepstream.io / dist / src / message / uws / socket-wrapper-factory.js View on Github external
sendPrepared(preparedMessage) {
        this.flush();
        uws.native.server.sendPrepared(this.external, preparedMessage);
    }
    /**

uws

## Go to [https://github.com/uNetworking/uWebSockets.js](https://github.com/uNetworking/uWebSockets.js).

Apache-2.0
Latest version published 4 years ago

Package Health Score

63 / 100
Full package analysis