How to use the minecraft-protocol/src.states function in minecraft-protocol

To help you get started, we’ve selected a few minecraft-protocol 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 deathcap / wsmc / minecraft-protocol-stream.js View on Github external
'use strict';

//process.env.NODE_DEBUG = 'mc-proto'; // for node-minecraft-protocol console packet debugging TODO: envify

var EmptyTransformStream = require('through')();
var Client = require('minecraft-protocol/src').Client;
var forgeHandshake = require('minecraft-protocol-forge').forgeHandshake;
var protocol = require('minecraft-protocol/src');
var assert = require('assert');
var states = protocol.states;

module.exports = {
  protocol: protocol,
  createClient: createClient
};

// generic stream version of index.js createClient()
function createClient(options) {
  assert.ok(options, "options is required");
  var stream = options.stream;
  assert.ok(stream, "stream is required");

  assert.ok(options.username, "username is required");
  var keepAlive = options.keepAlive == null ? true : options.keepAlive;

  var optVersion = options.version || require('./mcversion.js');