JSONToDatabase(json) { return new mongodb.Binary(Buffer.from(json.base64, 'base64')); }
isValidDatabaseObject(object) { return object instanceof mongodb.Binary || this.isBase64Value(object); }
/** * generate overwrite params object * @param {object} req * @param {ImportOptionForPages} option * @return object * key: property name * value: any value or a function `(value, { document, schema, propertyName }) => { return newValue }` */ static generate(req, option) { const params = {}; // Date params.files_id = (value, { document, schema, propertyName }) => { return ObjectId(value); }; // Binary params.data = (value, { document, schema, propertyName }) => { return Binary(value); }; return params; }
__putLong(v) { this.__put(minejs.utils.Binary.writeLong(v)); }
decode() { super.decode(); this.seqNumber = this.__getLTriad(); while (!this.__feof()) { let data = minejs.utils.Binary.subBytes(this.buffer, this.offset); let packet = minejs.raknet.protocol.EncapsulatedPacket.fromBinary(data, false); this.__offset += packet.getOffset(); if (packet.buffer.length == 0) break; this.packets.add(packet); } }
streamEncapsulated(session, packet, flags) { let id = session.getAddress() + ":" + session.getPort(); let idBytes = []; for (let i = 0; i < id.length; ++i) { idBytes.push(id.charCodeAt(i)); } let buffer = minejs.utils.Binary.appendBytes( minejs.raknet.RakNet.PACKET_ENCAPSULATED, [id.length() & 0xff], idBytes, [flags & 0xff], packet.toBinary(true) ); this.receiveStream(buffer); }
streamInvalid(identifier) { let identifierByte = []; for (let i = 0; i < identifier.length; ++i) { identifierByte.push(identifier.charCodeAt(i)); } let buffer = minejs.utils.Binary.appendBytes( minejs.raknet.RakNet.PACKET_INVALID_SESSION, [identifier.length() & 0xff], identifierByte ); this.receiveStream(buffer); }
__getShort() { return minejs.utils.Binary.readShort(this.__get(2)); }
function typedWriteEncodeValue(buffer, offset, type, value) { switch (type) { case PCCCDataType.Binary: case PCCCDataType.Byte: return buffer.writeUInt8(value, offset); case 'INT': case PCCCDataType.Integer: return buffer.writeUInt16LE(value, offset); case 'DINT': return buffer.writeUInt32LE(value, offset); case 'REAL': case PCCCDataType.Float: return buffer.writeFloatLE(value, offset); default: throw new Error(`Unable to encode value of type: ${type}`); } }
streamRAW(address, port, payload) { let addressByte = []; for (let i = 0; i < address.length; ++i) { addressByte.push(address.charCodeAt(i)); } let buffer = minejs.utils.Binary.appendBytes( minejs.raknet.RakNet.PACKET_RAW, [(address.length() & 0xff)], addressByte, minejs.utils.Binary.writeShort(port), payload ); this.receiveStream(buffer); }
__putInt(v) { this.__put(minejs.utils.Binary.writeInt(v)); }
__putTriad(v) { this.__put(minejs.utils.Binary.writeTriad(v)); }
streamACK(identifier, identifierACK) { let identifierByte = []; for (let i = 0; i < identifier.length; ++i) { identifierByte.push(identifier.charCodeAt(i)); } let buffer = minejs.utils.Binary.appendBytes( minejs.raknet.RakNet.PACKET_ACK_NOTIFICATION, [identifier.length() & 0xff], identifierByte, minejs.utils.Binary.writeInt(identifierACK) ); this.receiveStream(buffer); }
JSONToDatabase(json) { return new mongodb.Binary(Buffer.from(json.base64, 'base64')); }
isValidDatabaseObject(object) { return object instanceof mongodb.Binary || this.isBase64Value(object); }