How to use the bser.BunserBuf function in bser

To help you get started, we’ve selected a few bser 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 facebook / watchman / node / index.js View on Github external
function makeSock(sockname) {
    // bunser will decode the watchman BSER protocol for us
    self.bunser = new bser.BunserBuf();
    // For each decoded line:
    self.bunser.on('value', function(obj) {
      // Figure out if this is a unliteral response or if it is the
      // response portion of a request-response sequence.  At the time
      // of writing, there are only two possible unilateral responses.
      var unilateral = false;
      for (var i = 0; i < unilateralTags.length; i++) {
        var tag = unilateralTags[i];
        if (tag in obj) {
          unilateral = tag;
        }
      }

      if (unilateral) {
        self.emit(unilateral, obj);
      } else if (self.currentCommand) {
github facebook / metro / react-packager / src / SocketInterface / SocketClient.js View on Github external
console.error('uncaught error', error.stack);
          setImmediate(() => process.exit(1));
        });
        resolve(this);
      });
      this._sock.on('error', (e) => {
        e.message = `Error connecting to server on ${sockPath} ` +
                    `with error: ${e.message}`;
        e.message += getServerLogs();

        reject(e);
      });
    });

    this._resolvers = Object.create(null);
    const bunser = new bser.BunserBuf();
    this._sock.on('data', (buf) => bunser.append(buf));
    bunser.on('value', (message) => this._handleMessage(message));

    this._sock.on('close', () => {
      if (!this._closing) {
        const terminate = (result) => {
          const sockPathExists = fs.existsSync(sockPath);
          throw new Error(
            'Server closed unexpectedly.\n' +
            'Server ping connection attempt result: ' + result + '\n' +
            'Socket path: `' + sockPath + '` ' +
            (sockPathExists ? ' exists.' : 'doesn\'t exist') + '\n' +
            getServerLogs()
          );
        };
github fengjundev / DoubanMovie-React-Native / node_modules / react-native / packager / react-packager / src / SocketInterface / SocketClient.js View on Github external
debug('uncaught error', error.stack);
          setImmediate(() => process.exit(1));
        });
        resolve(this);
      });
      this._sock.on('error', (e) => {
        e.message = `Error connecting to server on ${sockPath} ` +
                    `with error: ${e.message}`;
        e.message += getServerLogs();

        reject(e);
      });
    });

    this._resolvers = Object.create(null);
    const bunser = new bser.BunserBuf();
    this._sock.on('data', (buf) => bunser.append(buf));
    bunser.on('value', (message) => this._handleMessage(message));

    this._sock.on('close', () => {
      if (!this._closing) {
        const terminate = (result) => {
          const sockPathExists = fs.existsSync(sockPath);
          throw new Error(
            'Server closed unexpectedly.\n' +
            'Server ping connection attempt result: ' + result + '\n' +
            'Socket path: `' + sockPath + '` ' +
            (sockPathExists ? ' exists.' : 'doesn\'t exist') + '\n' +
            getServerLogs()
          );
        };
github facebook / metro / react-packager / src / SocketInterface / SocketServer.js View on Github external
_handleConnection(sock) {
    debug('connection to server', process.pid);

    const bunser = new bser.BunserBuf();
    sock.on('data', (buf) => bunser.append(buf));
    bunser.on('value', (m) => this._handleMessage(sock, m));
    bunser.on('error', (e) => {
      e.message = 'Unhandled error from the bser buffer. ' +
                  'Either error on encoding or message handling: \n' +
                  e.message;
      throw e;
    });
  }
github fengjundev / DoubanMovie-React-Native / node_modules / react-native / packager / react-packager / src / SocketInterface / SocketServer.js View on Github external
_handleConnection(sock) {
    debug('connection to server', process.pid);
    this._numConnections++;
    sock.on('close', () => this._numConnections--);

    const bunser = new bser.BunserBuf();
    sock.on('data', (buf) => bunser.append(buf));
    bunser.on('value', (m) => this._handleMessage(sock, m));
    bunser.on('error', (e) => {
      e.message = 'Unhandled error from the bser buffer. ' +
                  'Either error on encoding or message handling: \n' +
                  e.message;
      throw e;
    });
  }

bser

JavaScript implementation of the BSER Binary Serialization

MIT
Latest version published 5 years ago

Package Health Score

88 / 100
Full package analysis

Popular bser functions