How to use the bytebuffer.isByteBuffer function in bytebuffer

To help you get started, we’ve selected a few bytebuffer 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 DoctorMcKay / node-steam-user / components / friends.js View on Github external
g_ProcessPersonaSemaphore.wait(async (release) => {
			if (typeof user.last_logoff === 'number') {
				user.last_logoff = new Date(user.last_logoff * 1000);
			}

			if (typeof user.last_logon === 'number') {
				user.last_logon = new Date(user.last_logon * 1000);
			}

			if (typeof user.last_seen_online === 'number') {
				user.last_seen_online = new Date(user.last_seen_online * 1000);
			}

			if (typeof user.avatar_hash === 'object' && (Buffer.isBuffer(user.avatar_hash) || ByteBuffer.isByteBuffer(user.avatar_hash))) {
				let hash = user.avatar_hash.toString('hex');

				// handle default avatar
				if (hash === "0000000000000000000000000000000000000000") {
					hash = "fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb";
				}

				user.avatar_url_icon = "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/" + hash.substring(0, 2) + "/" + hash;
				user.avatar_url_medium = user.avatar_url_icon + "_medium.jpg";
				user.avatar_url_full = user.avatar_url_icon + "_full.jpg";
				user.avatar_url_icon += ".jpg";
			}

			// only delete rich_presence_string if we have confirmation that the user isn't in-game
			if ((user.rich_presence && user.rich_presence.length == 0) || user.gameid === '0') {
				delete user.rich_presence_string;
github DoctorMcKay / node-steam-client / lib / cm_client.js View on Github external
CMClient.prototype.send = function(header, body, callback) {
	// ignore any target job ID
	if (header.proto) {
		delete header.proto.jobid_target;
	} else {
		delete header.targetJobID;
	}

	if (ByteBuffer.isByteBuffer(body)) {
		body = body.toBuffer();
	}

	this._send(header, body, callback);
};
github DoctorMcKay / node-tf2 / classes / CEconItemAttribute.js View on Github external
this.defindex = defindex;
	this.value = null;
	this.details = details;

	if(typeof details.stored_as_integer !== 'undefined') {
		// It's a standard type attribute.
		if(ByteBuffer.isByteBuffer(value)) {
			if(details.stored_as_integer) {
				this.value = value.readUint32();
			} else {
				this.value = value.readFloat32();
			}
		} else {
			this.value = details.stored_as_integer ? parseInt(value, 10) : parseFloat(value);
		}
	} else if(details.attribute_type && ByteBuffer.isByteBuffer(value)) {
		// Parse it from a protobuf
		switch(details.attribute_type) {
			case 'string':
				this.value = Protos.CAttribute_String.decode(value).value;
				break;

			case 'item_slot_criteria':
				this.value = Protos.CAttribute_ItemSlotCriteria.decode(value).tags;
				break;

			case 'uint64':
				this.value = value.readUint64();
				break;

			case 'dynamic_recipe_component_defined_item':
				this.value = Protos.CAttribute_DynamicRecipeComponent.decode(value);
github DoctorMcKay / node-steam-client / lib / udp_connection.js View on Github external
case EUdpPacketType.ChallengeReq:
			data = new Buffer(0);
			break;

		case EUdpPacketType.Connect:
			var challenge = data;
			data = new Buffer(4);
			data.writeUInt32LE((challenge ^ CHALLENGE_MASK) >>> 0, 0);
			break;

		case EUdpPacketType.Disconnect:
			data = new Buffer(0);
			break;

		case EUdpPacketType.Data:
			if(ByteBuffer.isByteBuffer(data)) {
				data = data.toBuffer();
			}

			if(this.sessionKey) {
				data = SteamCrypto.symmetricEncrypt(data, this.sessionKey);
			}

			break;

		case EUdpPacketType.Datagram:
			data = new Buffer(0);
			break;

		default:
			this.emit('debug', "Tried to send bad packet type " + type);
			return;
github DoctorMcKay / node-steam-user / components / content_manifest.js View on Github external
exports.parse = function(buffer) {
	if (!ByteBuffer.isByteBuffer(buffer)) {
		buffer = ByteBuffer.wrap(buffer, ByteBuffer.LITTLE_ENDIAN);
	}

	var manifest = {};
	var magic;
	var meta;
	var length;

	while (buffer.remaining() > 0) {
		magic = buffer.readUint32();
		switch (magic) {
			case PROTOBUF_PAYLOAD_MAGIC:
				length = buffer.readUint32();
				manifest.files = Protos.ContentManifestPayload.decode(buffer.slice(buffer.offset, buffer.offset + length)).mappings;
				buffer.skip(length);
				break;
github seishun / node-steam-resources / steam_language_parser / generator / node_gen.js View on Github external
Steam.Internal[cnode.name].decode = function(buffer) {
    if (!ByteBuffer.isByteBuffer(buffer)) {
      buffer = ByteBuffer.wrap(buffer, ByteBuffer.LITTLE_ENDIAN);
    }
    
    var object = {};
    cnode.childNodes.forEach(function(prop) {
      var typestr = exports.emitType(prop.type);
      var size = code_generator.getTypeSize(prop);
      
      var defflags = prop.flags;
      var symname = prop.name;
      
      if (defflags == 'const') {
        return;
      }
      
      if (!size) {
github DoctorMcKay / node-globaloffensive / handlers.js View on Github external
function decodeProto(proto, encoded) {
	if (ByteBuffer.isByteBuffer(encoded)) {
		encoded = encoded.toBuffer();
	}

	let decoded = proto.decode(encoded);
	let objNoDefaults = proto.toObject(decoded, {"longs": String});
	let objWithDefaults = proto.toObject(decoded, {"defaults": true, "longs": String});
	return replaceDefaults(objNoDefaults, objWithDefaults);

	function replaceDefaults(noDefaults, withDefaults) {
		if (Array.isArray(withDefaults)) {
			return withDefaults.map((val, idx) => replaceDefaults(noDefaults[idx], val));
		}

		for (let i in withDefaults) {
			if (!withDefaults.hasOwnProperty(i)) {
				continue;
github DoctorMcKay / node-tf2 / handlers.js View on Github external
function decodeProto(proto, encoded) {
	if (ByteBuffer.isByteBuffer(encoded)) {
		encoded = encoded.toBuffer();
	}

	let decoded = proto.decode(encoded);
	let objNoDefaults = proto.toObject(decoded, {"longs": String});
	let objWithDefaults = proto.toObject(decoded, {"defaults": true, "longs": String});
	return replaceDefaults(objNoDefaults, objWithDefaults);

	function replaceDefaults(noDefaults, withDefaults) {
		if (Array.isArray(withDefaults)) {
			return withDefaults.map((val, idx) => replaceDefaults(noDefaults[idx], val));
		}

		for (let i in withDefaults) {
			if (!withDefaults.hasOwnProperty(i)) {
				continue;
github seishun / node-steam / resources / steam_language_parser / generator / node_gen.js View on Github external
Steam.Internal[cnode.name].decode = function(buffer) {
    if (!ByteBuffer.isByteBuffer(buffer)) {
      buffer = ByteBuffer.wrap(buffer, ByteBuffer.LITTLE_ENDIAN);
    }
    
    var object = {};
    cnode.childNodes.forEach(function(prop) {
      var typestr = exports.emitType(prop.type);
      var size = code_generator.getTypeSize(prop);
      
      var defflags = prop.flags;
      var symname = prop.name;
      
      if (defflags == 'const') {
        return;
      }
      
      if (!size) {