Fixed user data request/response definitions
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Jack Hadrill 2022-03-18 17:33:10 +00:00
parent be9b84de81
commit 0b19b83271
4 changed files with 16 additions and 2 deletions

View File

@ -57,6 +57,7 @@ export function unpackUserDataRequestMessage (data: Uint8Array): UserDataRequest
const usernameLength = packedData.readUInt16()
const username = packedData.readBytes(usernameLength)
packedData.cursor = 34
const colour = packedData.readBytes(3)
const clientIdLength = packedData.readUInt16()
const clientId = packedData.readBytes(clientIdLength)

View File

@ -56,6 +56,7 @@ export function unpackUserDataResponseMessage (data: Uint8Array): UserDataRespon
const usernameLength = packedData.readUInt16()
const username = packedData.readBytes(usernameLength)
packedData.cursor = 34
const colour = packedData.readBytes(3)
const clientIdLength = packedData.readUInt16()
const clientId = packedData.readBytes(clientIdLength)

View File

@ -31,7 +31,13 @@ test('Create a user data request (0x0002) packet.', () => {
test('Parse a user data request (0x0002).', () => {
// Given
const data = new Uint8Array([0, 12, 66, 117, 116, 108, 101, 114, 115, 97, 117, 114, 117, 115, 255, 64, 0, 0, 7, 77, 101, 114, 99, 117, 114, 121])
const data = new Uint8Array([
0, 12,
66, 117, 116, 108, 101, 114, 115, 97, 117, 114, 117, 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
255, 64, 0,
0, 7,
77, 101, 114, 99, 117, 114, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
])
const username = 'Butlersaurus'
const colour = Color('#FF4000')
const clientId = 'Mercury'

View File

@ -31,7 +31,13 @@ test('Create a user data response (0x0003) packet.', () => {
test('Parse a user data response (0x0003).', () => {
// Given
const data = new Uint8Array([0, 12, 66, 117, 116, 108, 101, 114, 115, 97, 117, 114, 117, 115, 255, 64, 0, 0, 7, 77, 101, 114, 99, 117, 114, 121])
const data = new Uint8Array([
0, 12,
66, 117, 116, 108, 101, 114, 115, 97, 117, 114, 117, 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
255, 64, 0,
0, 7,
77, 101, 114, 99, 117, 114, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
])
const username = 'Butlersaurus'
const colour = Color('#FF4000')
const clientId = 'Mercury'