API reference / @jsprismarine/raknet / ConnectionRequest
Class: ConnectionRequest
Defined in: raknet/src/protocol/login/ConnectionRequest.ts:11
The first message inside the connection, opening the connected handshake.
Wire layout: id, clientGUID (uint64), requestTimestamp as an unsigned 64 bit RakNet::Time, then a security byte that is always 0 for Bedrock.
See
https://github.com/facebookarchive/RakNet/blob/master/Source/RakPeer.cpp#L5006
Extends
Constructors
Constructor
new ConnectionRequest(
buffer?):ConnectionRequest
Defined in: raknet/src/protocol/login/ConnectionRequest.ts:12
Parameters
buffer?
Buffer<ArrayBufferLike>
Returns
ConnectionRequest
Overrides
Properties
clientGUID
clientGUID:
bigint
Defined in: raknet/src/protocol/login/ConnectionRequest.ts:16
requestTimestamp
requestTimestamp:
bigint
Defined in: raknet/src/protocol/login/ConnectionRequest.ts:17
Methods
clear()
clear():
void
Defined in: binaryutils/src/BinaryStream.ts:977
Clears the whole BinaryStream instance.
The write buffer and its capacity are kept, so any view previously returned by getWriteBuffer is invalidated. See resetWrite.
Returns
void
Inherited from
copyInto()
copyInto(
target,offset?):number
Defined in: binaryutils/src/BinaryStream.ts:856
Copies the encoded bytes into a caller-owned buffer at offset and returns the offset just past them. Lets many packets be encoded into one arena with no per-packet allocation at all.
Parameters
target
Buffer
offset?
number = 0
Returns
number
the new offset
Inherited from
copyOut()
copyOut():
Buffer
Defined in: binaryutils/src/BinaryStream.ts:840
Returns the encoded bytes as an exactly-sized, standalone Buffer.
Unlike getWriteBuffer the result does not alias this stream, so it survives resetWrite, and it does not pin a pool chunk: because Buffer.allocUnsafe is pool-backed (Buffer.poolSize is 64 KB on current Node), holding on to a handful of small slices from getWriteBuffer can keep megabytes alive.
Returns
Buffer
Inherited from
decode()
decode():
void
Defined in: raknet/src/protocol/Packet.ts:117
Returns
void
Inherited from
decodePayload()
decodePayload():
void
Defined in: raknet/src/protocol/login/ConnectionRequest.ts:19
Returns
void
Overrides
Packet.decodePayload
encode()
encode():
void
Defined in: raknet/src/protocol/Packet.ts:124
Returns
void
Inherited from
encodePayload()
encodePayload():
void
Defined in: raknet/src/protocol/login/ConnectionRequest.ts:25
Returns
void
Overrides
Packet.encodePayload
feof()
feof():
boolean
Defined in: binaryutils/src/BinaryStream.ts:875
Returns whatever or not the read offset is at end of line.
Returns
boolean
Inherited from
getBuffer()
getBuffer():
Buffer
Defined in: binaryutils/src/BinaryStream.ts:912
Returns the encoded buffer.
Beware: when a read buffer is present this returns that, discarding everything written. On a stream used for both reading and writing it never returns your output.
Returns
Buffer
Deprecated
See getReadBuffer and getWriteBuffer.
Inherited from
getId()
getId():
number
Defined in: raknet/src/protocol/Packet.ts:113
Get the packet ID.
Returns
number
The packet's ID.
Inherited from
getReadBuffer()
getReadBuffer():
Buffer<ArrayBufferLike> |null
Defined in: binaryutils/src/BinaryStream.ts:920
Returns the read buffer if available.
Returns
Buffer<ArrayBufferLike> | null
Inherited from
getReadIndex()
getReadIndex():
number
Defined in: binaryutils/src/BinaryStream.ts:1019
Retuns the read index.
Returns
number
Inherited from
getWriteBuffer()
getWriteBuffer():
Buffer
Defined in: binaryutils/src/BinaryStream.ts:936
Returns the encoded bytes as a view over this stream's internal buffer.
The view is only valid until the next write: resetWrite, clear and reuse all rewind the cursor without reallocating, so a previously returned buffer is silently overwritten by the next packet. If you queue the result - a send queue, a resend window - use copyOut or copyInto instead.
It also keeps the whole pooled 64 KB chunk it was carved from alive; retaining a scattered handful of small packets this way can pin megabytes.
Returns
Buffer
Inherited from
getWriteIndex()
getWriteIndex():
number
Defined in: binaryutils/src/BinaryStream.ts:1027
Returns the write index.
Returns
number
Inherited from
read()
read(
len):Buffer
Defined in: binaryutils/src/BinaryStream.ts:62
Reads a slice of buffer by the given length.
Parameters
len
number
How many bytes to read: a nonnegative integer.
Returns
Buffer
Throws
AssertionError when len is negative or not an integer, or runs past the end.
Inherited from
readAddress()
readAddress():
InetAddress
Defined in: raknet/src/protocol/Packet.ts:159
Reads a RakNet SystemAddress.
A version byte, then for IPv4 the four complemented octets and the port as an unsigned big-endian short. Anything else is IPv6, which RakNet writes as the raw sockaddr_in6: family, port, flow info, the 16 address bytes, then the scope id. The port is unsigned because RakNet serializes it as unsigned short; read signed, every ephemeral port from 32768 up came back negative.
Returns
See
https://github.com/facebookarchive/RakNet/blob/master/Source/BitStream.h#L1494
Inherited from
readBoolean()
readBoolean():
boolean
Defined in: binaryutils/src/BinaryStream.ts:179
Reads a boolean (true or false).
Returns
boolean
Inherited from
readByte()
readByte():
number
Defined in: binaryutils/src/BinaryStream.ts:143
Reads an unsigned byte (0 to 255).
Returns
number
Inherited from
readDouble()
readDouble():
number
Defined in: binaryutils/src/BinaryStream.ts:481
Returns a 64 bit (8 bytes) big-endian flating point number.
Returns
number
Inherited from
readDoubleLE()
readDoubleLE():
number
Defined in: binaryutils/src/BinaryStream.ts:501
Returns a 64 bit (8 bytes) little-endian flating point number.
Returns
number
Inherited from
readFloat()
readFloat():
number
Defined in: binaryutils/src/BinaryStream.ts:441
Returns a 32 bit (4 bytes) big-endian flating point number.
Returns
number
Inherited from
readFloatLE()
readFloatLE():
number
Defined in: binaryutils/src/BinaryStream.ts:461
Returns a 32 bit (4 bytes) big-endian flating point number.
Returns
number
Inherited from
readInt()
readInt():
number
Defined in: binaryutils/src/BinaryStream.ts:361
Reads a 32 bit (4 bytes) big-endian signed number.
Returns
number
Inherited from
readIntLE()
readIntLE():
number
Defined in: binaryutils/src/BinaryStream.ts:381
Reads a 32 bit (4 bytes) signed number.
Returns
number
Inherited from
readLengthPrefixed()
readLengthPrefixed():
Buffer
Defined in: binaryutils/src/BinaryStream.ts:107
Reads a varuint32 byte length, then that many bytes.
Returns
Buffer
The bytes, a view into the stream's buffer.
Inherited from
readLong()
readLong():
bigint
Defined in: binaryutils/src/BinaryStream.ts:521
Returns a 64 bit (8 bytes) signed big-endian number.
Returns
bigint
Inherited from
readLongLE()
readLongLE():
bigint
Defined in: binaryutils/src/BinaryStream.ts:540
Returns a 64 bit (8 bytes) signed little-endian number.
Returns
bigint
Inherited from
readRemaining()
readRemaining():
Buffer
Defined in: binaryutils/src/BinaryStream.ts:888
Reads the remaining bytes and returns the buffer slice.
Returns
Buffer
Inherited from
readShort()
readShort():
number
Defined in: binaryutils/src/BinaryStream.ts:197
Reads a 16 bit (2 bytes) signed big-endian number.
Returns
number
Inherited from
readShortLE()
readShortLE():
number
Defined in: binaryutils/src/BinaryStream.ts:217
Reads a 16 bit (2 bytes) signed little-endian number.
Returns
number
Inherited from
readSignedByte()
readSignedByte():
number
Defined in: binaryutils/src/BinaryStream.ts:161
Reads a signed byte (-128 to 127).
Returns
number
Inherited from
readString()
readString():
string
Defined in: raknet/src/protocol/Packet.ts:139
Reads a RakNet string: an unsigned 16 bit big-endian byte length, then the bytes.
Unsigned to match writeString, which has always written the length with writeUnsignedShort. Read signed, any string of 32768 bytes or more came back with a negative length, and read then walked the cursor backwards over data it had already consumed instead of failing.
Returns
string
Inherited from
readTriad()
readTriad():
number
Defined in: binaryutils/src/BinaryStream.ts:277
Reads a 24 bit (3 bytes) signed big-endian number.
Returns
number
Inherited from
readTriadLE()
readTriadLE():
number
Defined in: binaryutils/src/BinaryStream.ts:298
Reads a 24 bit (3 bytes) little-endian number.
Returns
number
Inherited from
readUnsignedInt()
readUnsignedInt():
number
Defined in: binaryutils/src/BinaryStream.ts:401
Reads a 32 bit (4 bytes) big-endian unsigned number.
Returns
number
Inherited from
readUnsignedIntLE()
readUnsignedIntLE():
number
Defined in: binaryutils/src/BinaryStream.ts:421
Reads a 32 bit (4 bytes) little-endian unsigned number.
Returns
number
Inherited from
readUnsignedLong()
readUnsignedLong():
bigint
Defined in: binaryutils/src/BinaryStream.ts:559
Returns a 64 bit (8 bytes) unsigned big-endian number.
Returns
bigint
Inherited from
readUnsignedLongLE()
readUnsignedLongLE():
bigint
Defined in: binaryutils/src/BinaryStream.ts:578
Returns a 64 bit (8 bytes) unsigned little-endian number.
Returns
bigint
Inherited from
readUnsignedShort()
readUnsignedShort():
number
Defined in: binaryutils/src/BinaryStream.ts:237
Reads a 16 bit (2 bytes) unsigned big-endian number.
Returns
number
Inherited from
readUnsignedShortLE()
readUnsignedShortLE():
number
Defined in: binaryutils/src/BinaryStream.ts:257
Reads a 16 bit (2 bytes) unsigned little-endian number.
Returns
number
Inherited from
readUnsignedTriad()
readUnsignedTriad():
number
Defined in: binaryutils/src/BinaryStream.ts:319
Reads a 24 bit (3 bytes) unsigned big-endian number.
Returns
number
Inherited from
readUnsignedTriadLE()
readUnsignedTriadLE():
number
Defined in: binaryutils/src/BinaryStream.ts:340
Reads a 24 bit (3 bytes) unsigned little-endian number.
Returns
number
Inherited from
readUnsignedVarInt()
readUnsignedVarInt():
number
Defined in: binaryutils/src/BinaryStream.ts:619
Reads a 32 bit unsigned number.
Returns
number
Inherited from
readUnsignedVarLong()
readUnsignedVarLong():
bigint
Defined in: binaryutils/src/BinaryStream.ts:702
Reads a 64 bit unsigned variable-length number.
Returns
bigint
Inherited from
readVarInt()
readVarInt():
number
Defined in: binaryutils/src/BinaryStream.ts:597
Reads a 32 bit (4 bytes) zigzag-encoded number.
Returns
number
Inherited from
readVarLong()
readVarLong():
bigint
Defined in: binaryutils/src/BinaryStream.ts:675
Reads a 64 bit zigzag-encoded variable-length number.
Returns
bigint
Inherited from
readVarString()
readVarString():
string
Defined in: binaryutils/src/BinaryStream.ts:126
Reads a string: a varuint32 byte length, then UTF-8 bytes, the form Bedrock writes strings in. Named apart from readString because RakNet's packets read theirs with a u16 length. The docs' string primitive
Returns
string
The read string.
Inherited from
reserve()
reserve(
capacity):this
Defined in: binaryutils/src/BinaryStream.ts:805
Grows the write buffer so that at least capacity bytes can be written without any further allocation, and returns this stream.
Pre-sizing skips the 256 -> 512 -> 1024 ... growth ladder, each step of which copies the whole payload; a 3 KB packet starting from the 256-byte floor performs five allocations and memcpy's 1.25x its own size before it is done.
Parameters
capacity
number
Returns
this
Inherited from
resetWrite()
resetWrite():
void
Defined in: binaryutils/src/BinaryStream.ts:827
Rewinds the write cursor while keeping the allocated capacity, so a long-lived encoder reaches a steady state where it never allocates again. This is the intended way to reuse a stream for many packets.
Note the aliasing contract, which it shares with clear and reuse: any buffer previously handed out by getWriteBuffer is a view over this stream's memory and is invalidated by this call. Use copyOut or copyInto for output you intend to keep.
Returns
void
Inherited from
reuse()
reuse(
buf):void
Defined in: binaryutils/src/BinaryStream.ts:991
Conventional method to reuse the stream without having to create a new BinaryStream instance.
The write buffer and its capacity are kept, so any view previously returned by getWriteBuffer is invalidated. See resetWrite.
Parameters
buf
Buffer
The new buffer instance.
Returns
void
Inherited from
setBuffer()
setBuffer(
buf):void
Defined in: binaryutils/src/BinaryStream.ts:946
Sets the buffer for reading. make sure to reset the reading index!
Parameters
buf
Buffer
The new Buffer.
Returns
void
Deprecated
See setReadBuffer and setWriteBuffer.
Inherited from
setReadBuffer()
setReadBuffer(
buf,rIndex?):void
Defined in: binaryutils/src/BinaryStream.ts:955
Sets the buffer for reading.
Parameters
buf
Buffer
The new Buffer.
rIndex?
number = 0
The new read index (default: 0, pass -1 to keep current).
Returns
void
Inherited from
setReadIndex()
setReadIndex(
index):void
Defined in: binaryutils/src/BinaryStream.ts:1001
Sets the reading index.
Parameters
index
number
The new read index.
Returns
void
Inherited from
setWriteBuffer()
setWriteBuffer(
buf,wIndex?):void
Defined in: binaryutils/src/BinaryStream.ts:965
Sets the buffer for writing.
Parameters
buf
Buffer
The new Buffer.
wIndex?
number = 0
The new write index (default: 0, pass -1 to keep current).
Returns
void
Inherited from
setWriteIndex()
setWriteIndex(
index):void
Defined in: binaryutils/src/BinaryStream.ts:1010
Sets the new writing index.
Parameters
index
number
The new write index.
Returns
void
Inherited from
skip()
skip(
len):void
Defined in: binaryutils/src/BinaryStream.ts:899
Skips len bytes on the buffer.
Parameters
len
number
Returns
void
Inherited from
write()
write(
buf):void
Defined in: binaryutils/src/BinaryStream.ts:76
Appends a buffer to the main buffer.
Parameters
buf
Uint8Array
Returns
void
Inherited from
writeAddress()
writeAddress(
address):void
Defined in: raknet/src/protocol/Packet.ts:184
Writes a RakNet SystemAddress, the mirror of readAddress.
The flow info and scope id of an IPv6 address are written as zero: Bedrock does the same, and the peer has no use for a scope that only means something on our host.
Parameters
address
Returns
void
Throws
When the address text is not a valid address of its version.
See
https://github.com/facebookarchive/RakNet/blob/master/Source/BitStream.h#L1142
Inherited from
writeBoolean()
writeBoolean(
v):void
Defined in: binaryutils/src/BinaryStream.ts:188
Writes a boolean (true or false).
Parameters
v
boolean
Returns
void
Inherited from
writeByte()
writeByte(
v):void
Defined in: binaryutils/src/BinaryStream.ts:152
Writes an unsigned byte (0 to 255).
Parameters
v
number
Returns
void
Inherited from
writeDouble()
writeDouble(
v):void
Defined in: binaryutils/src/BinaryStream.ts:490
Writes a 64 bit (8 bytes) big-endian floating point number.
Parameters
v
number
Returns
void
Inherited from
writeDoubleLE()
writeDoubleLE(
v):void
Defined in: binaryutils/src/BinaryStream.ts:510
Writes a 64 bit (8 bytes) little-endian floating point number.
Parameters
v
number
Returns
void
Inherited from
writeFloat()
writeFloat(
v):void
Defined in: binaryutils/src/BinaryStream.ts:450
Writes a 32 bit (4 bytes) big-endian floating point number.
Parameters
v
number
Returns
void
Inherited from
writeFloatLE()
writeFloatLE(
v):void
Defined in: binaryutils/src/BinaryStream.ts:470
Writes a 32 bit (4 bytes) little-endian floating point number.
Parameters
v
number
Returns
void
Inherited from
writeInt()
writeInt(
v):void
Defined in: binaryutils/src/BinaryStream.ts:370
Writes a 32 bit (4 bytes) big-endian signed number.
Parameters
v
number
Returns
void
Inherited from
writeIntLE()
writeIntLE(
v):void
Defined in: binaryutils/src/BinaryStream.ts:390
Writes a 32 bit (4 bytes) little-endian signed number.
Parameters
v
number
Returns
void
Inherited from
writeLengthPrefixed()
writeLengthPrefixed(
buf):void
Defined in: binaryutils/src/BinaryStream.ts:115
Writes a varuint32 byte length, then the bytes.
Parameters
buf
Uint8Array
The bytes to append.
Returns
void
Inherited from
writeLong()
writeLong(
v):void
Defined in: binaryutils/src/BinaryStream.ts:530
Writes a 64 bit (8 bytes) signed big-endian number.
Parameters
v
bigint
Returns
void
Inherited from
writeLongLE()
writeLongLE(
v):void
Defined in: binaryutils/src/BinaryStream.ts:549
Writes a 64 bit (8 bytes) signed little-endian number.
Parameters
v
bigint
Returns
void
Inherited from
writeShort()
writeShort(
v):void
Defined in: binaryutils/src/BinaryStream.ts:206
Writes a 16 bit (2 bytes) signed big-endian number.
Parameters
v
number
Returns
void
Inherited from
writeShortLE()
writeShortLE(
v):void
Defined in: binaryutils/src/BinaryStream.ts:226
Writes a 16 bit (2 bytes) signed little-endian number.
Parameters
v
number
Returns
void
Inherited from
writeSignedByte()
writeSignedByte(
v):void
Defined in: binaryutils/src/BinaryStream.ts:170
Writes a signed byte (-128 to 127).
Parameters
v
number
Returns
void
Inherited from
writeString()
writeString(
v):void
Defined in: raknet/src/protocol/Packet.ts:143
Parameters
v
string
Returns
void
Inherited from
writeTriad()
writeTriad(
v):void
Defined in: binaryutils/src/BinaryStream.ts:286
Writes a 24 bit (3 bytes) signed big-endian number.
Parameters
v
number
Returns
void
Inherited from
writeTriadLE()
writeTriadLE(
v):void
Defined in: binaryutils/src/BinaryStream.ts:307
Writes a 24 bit (3 bytes) signed little-endian number.
Parameters
v
number
Returns
void
Inherited from
writeUnsignedInt()
writeUnsignedInt(
v):void
Defined in: binaryutils/src/BinaryStream.ts:410
Writes a 32 bit (4 bytes) big-endian unsigned number.
Parameters
v
number
Returns
void
Inherited from
writeUnsignedIntLE()
writeUnsignedIntLE(
v):void
Defined in: binaryutils/src/BinaryStream.ts:430
Writes a 32 bit (4 bytes) little-endian unsigned number.
Parameters
v
number
Returns
void
Inherited from
writeUnsignedLong()
writeUnsignedLong(
v):void
Defined in: binaryutils/src/BinaryStream.ts:568
Writes a 64 bit (8 bytes) unsigned big-endian number.
Parameters
v
bigint
Returns
void
Inherited from
writeUnsignedLongLE()
writeUnsignedLongLE(
v):void
Defined in: binaryutils/src/BinaryStream.ts:587
Writes a 64 bit (8 bytes) unsigned little-endian number.
Parameters
v
bigint
Returns
void
Inherited from
writeUnsignedShort()
writeUnsignedShort(
v):void
Defined in: binaryutils/src/BinaryStream.ts:246
Writes a 16 bit (2 bytes) unsigned big-endian number.
Parameters
v
number
Returns
void
Inherited from
writeUnsignedShortLE()
writeUnsignedShortLE(
v):void
Defined in: binaryutils/src/BinaryStream.ts:266
Writes a 16 bit (2 bytes) unsigned little-endian number.
Parameters
v
number
Returns
void
Inherited from
writeUnsignedTriad()
writeUnsignedTriad(
v):void
Defined in: binaryutils/src/BinaryStream.ts:328
Writes a 24 bit (3 bytes) unsigned big-endian number.
Parameters
v
number
Returns
void
Inherited from
writeUnsignedTriadLE()
writeUnsignedTriadLE(
v):void
Defined in: binaryutils/src/BinaryStream.ts:349
Writes a 24 bit (3 bytes) unsigned little-endian number.
Parameters
v
number
Returns
void
Inherited from
writeUnsignedVarInt()
writeUnsignedVarInt(
v):void
Defined in: binaryutils/src/BinaryStream.ts:657
Writes a 32 bit unsigned number with variable-length.
Parameters
v
number
Returns
void
Inherited from
writeUnsignedVarLong()
writeUnsignedVarLong(
v):void
Defined in: binaryutils/src/BinaryStream.ts:742
Writes a 64 bit unsigned variable-length number.
Parameters
v
bigint
Returns
void
Inherited from
writeUTF8String()
writeUTF8String(
value):void
Defined in: binaryutils/src/BinaryStream.ts:91
Writes a UTF-8 string directly into the stream's backing buffer.
Parameters
value
string
The string to encode.
Returns
void
Inherited from
writeVarInt()
writeVarInt(
v):void
Defined in: binaryutils/src/BinaryStream.ts:609
Writes a 32 bit (4 bytes) zigzag-encoded number.
Parameters
v
number
Returns
void
Inherited from
writeVarLong()
writeVarLong(
v):void
Defined in: binaryutils/src/BinaryStream.ts:688
Writes a 64 bit unsigned zigzag-encoded number.
Parameters
v
bigint
Returns
void
Inherited from
writeVarString()
writeVarString(
str):void
Defined in: binaryutils/src/BinaryStream.ts:134
Writes a string as a varuint32 byte length, then UTF-8 bytes.
Parameters
str
string
The string to write.
Returns
void